iOS网络校验,检测网络来源。
+(void)netWorkState:(void(^)(NSInteger netState)) block
{ AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
[manager startMonitoring];
[manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
if (status==0||status==-1) {
block(0);
}else{
block(status);
}
}];
}
@return 网络监测 0:无网络 1:WWAN 2:wifi