美文网首页
Reachability检查网络状态注意

Reachability检查网络状态注意

作者: wonderstruck | 来源:发表于2016-09-14 12:13 被阅读16次

直接看下代码
//在有网的情况下没次刷新数据
Reachability *reachability = [Reachability reachabilityWithHostname:KTEST_URL];
NetworkStatus status = [reachability currentReachabilityStatus];

if (status != NotReachable) {
//有网刷新数据
    [self _loadData];
}

define KTEST_URL @"www.baidu.com"

因为之前写的KTEST_URL为@"https://www.baidu.com",在iOS7下有网的时候也总检测为没网,Hostnam去掉https://就判断正确OK了。
所以要了解点https协议,也要细心噢~

相关文章

网友评论

      本文标题:Reachability检查网络状态注意

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