#import "AFNetworking.h"
/** 网络状态检查者 */
@property(nonatomic,strong)AFNetworkReachabilityManager*networkMonitorManager;
- (void)netWorkReachabilityStatus{
// 开启网络监听
ws
[self.networkMonitorManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
if (status == AFNetworkReachabilityStatusNotReachable) {// 没有网络
NSLog(@"暂时没有网络");
}else{// 有网络
NSLog(@"有网络");
}
}];
}
- (AFNetworkReachabilityManager*)networkMonitorManager {
if (!_networkMonitorManager) {
_networkMonitorManager = [AFNetworkReachabilityManager sharedManager];
[_networkMonitorManager startMonitoring]; //开始监听
}
return _networkMonitorManager;
}