1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| -(void)startNetWorkMonitor { AFNetworkReachabilityManager *mgr=[AFNetworkReachabilityManager sharedManager]; [mgr setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { switch (status) { case AFNetworkReachabilityStatusReachableViaWiFi: NSLog(@"WIFI"); break; case AFNetworkReachabilityStatusReachableViaWWAN: NSLog(@"自带网路"); break; case AFNetworkReachabilityStatusNotReachable: NSLog(@"没有网络"); break; case AFNetworkReachabilityStatusUnknown: NSLog(@"未知网络"); break; default: NSLog(@"其他"); break; } }]; //开始监控 [mgr startMonitoring]; } -(void)dealloc { [[AFNetworkReachabilityManager sharedManager]stopMonitoring]; }
|