检查iPad是否具有路由到Internet的能力

时间:2013-12-04 09:22:18

标签: ios objective-c ipad wifi

如何检查iPad是否有能力上网?我想要两个不同的东西,一个是检查我是否可以使用以下可更换性代码,但现在我想检查iPad是否有能力路由到互联网。我怎么能这样做?

  Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];

if (networkStatus == NotReachable) {
    NSLog(@"There IS NO internet connection");
} else {
    NSLog(@"There IS internet connection");
   }

1 个答案:

答案 0 :(得分:-1)

您可以使用该代码查找设备上的连接类型。

wan = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [wan currentReachabilityStatus];
if (networkStatus == ReachableViaWWAN) {

}

wifi = [Reachability reachabilityForLocalWiFi];
NetworkStatus networkStatus = [wifi currentReachabilityStatus];
if (networkStatus == ReachableViaWiFi) {

}