ios-ASIHTTPRequest的Reachability可以监听网络,网络出现状况来不同的处理

 _reacheability= [Reachability reachabilityForInternetConnection];//我们可以用这个类来监听网络,这个不同的网络用不同的静态方法初始化
 [_reacheability startNotifier];//开始监测网络
 NetworkStatus staus=[_reacheability currentReachabilityStatus];//获取当前网络状态
 [self networkstaus:staus];
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkChange:) name:kReachabilityChangedNotification object:nil];//给通知中心一个通知,有变化通知我

-(void)networkChange:(NSNotification *)notices{
    NetworkStatus staus=[_reacheability currentReachabilityStatus];//获取当前网络状态
    [self networkstaus:staus];
}
-(void)networkstaus:(NetworkStatus)status{
    if (status==kNotReachable) {
        NSLog(@"没有网络");
    }else if (status==kReachableViaWiFi) {
        NSLog(@"kReachableViaWiFi");
    }else if (status==kReachableViaWWAN) {
        NSLog(@"kReachableViaWWAN");
    }
}
//2个调用的方法


 
1.这里只记录一些学习笔记 2.这里只记录一些学习心得,如果心得方向有错,请留言 2.这里只记录一些日记(只为提升英语,暂时有点忙,等转行了开始写)
原文地址:https://www.cnblogs.com/liyang31tg/p/3665012.html