美文网首页
AFN检测网络

AFN检测网络

作者: c42b9af86268 | 来源:发表于2017-05-25 10:26 被阅读0次

    /**

    监测网络的可链接性

    @param strUrl URL地址

    @return 是否可达

    */

    +(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;

    }

    相关文章

      网友评论

          本文标题:AFN检测网络

          本文链接:https://www.haomeiwen.com/subject/zqhvzttx.html