在初始化 AFNetworkReachabilityManager 後,會調用 startMonitoring 方法開始監控網絡狀態:
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
檢查網路狀態副程式:
- (BOOL)checkNetworkStatus { Debug("network status=%@\n", [[AFNetworkReachabilityManager sharedManager] localizedNetworkReachabilityStatusString]); if (![[AFNetworkReachabilityManager sharedManager] isReachable]) { [Utils alertWithTitle:NSLocalizedString(@"Network unavailable", nil) message:nil handler:nil from:self]; return NO; } return YES; }