- (void)isNetworking
{
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager ] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case -1:
NSLog(@"未知网络");
break;
case 0:
NSLog(@"网络不可达");
break;
case 1:
NSLog(@"GPRS网络");
break;
case 2:
NSLog(@"wifi网络");
break;
default:
break;
}
if(status ==AFNetworkReachabilityStatusReachableViaWWAN || status == AFNetworkReachabilityStatusReachableViaWiFi)
{
NSLog(@"有网");
}
else
{
NSLog(@"没有网");
[MBProgressHUD showError:@"请检查网络连接" toView:[UIApplication sharedApplication].keyWindow];
}
}];
}
网友评论