网络状态监听

//监听网络
    AFNetworkReachabilityManager *netManager = [AFNetworkReachabilityManager sharedManager];
    [netManager startMonitoring];  //开始监听
    [netManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status){
        
        if (status == AFNetworkReachabilityStatusNotReachable)
        {
            //showAlert
//            [EPProgressHUD showErrorWithStatus:@"网络链接错误,请检查网络链接"];
            
            return;
        }else if (status == AFNetworkReachabilityStatusUnknown){
            
            DLog(@"未知网络");
            [EPProgressHUD showErrorWithStatus:@"未知网络"];
            
        }else if ((status == AFNetworkReachabilityStatusReachableViaWWAN)||(status == AFNetworkReachabilityStatusReachableViaWiFi)){
            
            DLog(@"WiFi");
             [self set_NetWork];
            
        }
        
    }];

你可能感兴趣的:(网络状态监听)