/**
監(jiān)測(cè)網(wǎng)絡(luò)的可鏈接性
@param strUrl URL地址
@return 是否可達(dá)
*/
+(BOOL)netWorkReachabilityWithURLString:(NSString *) strUrl {
__block BOOL netState = YES;
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
switch (status) {
case AFNetworkReachabilityStatusNotReachable:
case AFNetworkReachabilityStatusUnknown:
netState = NO;
break;
case AFNetworkReachabilityStatusReachableViaWiFi:
case AFNetworkReachabilityStatusReachableViaWWAN:
netState = YES;
break;
default:
break;
}
NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status));
}];
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
return netState;
}