如何知道iOS是否打开wifi?

时间:2015-03-31 08:17:05

标签: ios wifi

我只是想知道wifi是否打开,因为我的应用只是希望用户打开wifi按钮,他们根本不需要连接wifi。 但我无法得到用户是否已经开启wifi的消息..

2 个答案:

答案 0 :(得分:0)

使用Rechability类,它是Apple的Reachability类的替代品。它与ARC兼容,它使用新的GCD方法来通知网络接口的变化。

下载并查看以下链接。

Download Rechability from here

答案 1 :(得分:0)

要检查互联网连接,请使用以下代码

Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
if (networkStatus == NotReachable) {
    NSLog(@"Internet connection available");
} else {
    NSLog(@"Internet connection not available");
}

检查Apple Reachability

中的示例代码