AFNetWorking 检测网络状态
AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusUnknown:
{
NSLog(@"未识别的网络");
break;
}
case AFNetworkReachabilityStatusNotReachable:
{
NSLog(@"不可达的网络(未连接)");
break;
}
case AFNetworkReachabilityStatusReachableViaWWAN:
{
NSLog(@"2G,3G,4G...的网络");
self.haveNetWorkAbility = YES;
[self competitionModelNetWork];
break;
}
case AFNetworkReachabilityStatusReachableViaWiFi:
{
NSLog(@"wifi的网络");
break;
}
default:
DLog(@"网络状态的默认");
break;
}
}];
[manager startMonitoring];
// 是一个监听 只要状态变化就会调用