//网络检测 // 1.创建网络监听者管理者对象 AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager]; // -设置网络监听 [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { switch (status) { case AFNetworkReachabilityStatusUnknown: NSLog(@"未识别的网络"); break; case AFNetworkReachabilityStatusNotReachable: NSLog(@"不可达的网络(未连接)"); break; case AFNetworkReachabilityStatusReachableViaWWAN: NSLog(@"2G,3G,4G...的网络"); break; case AFNetworkReachabilityStatusReachableViaWiFi: NSLog(@"wifi的网络"); break; default: break; } }]; // 3.开始监听 [manager startMonitoring];
pod ‘AFNetworking‘, ‘~> 3.1.0‘