You can use FBNetworkReachabilty class to get network reachability on iOS device.
你可以用FBNetworkReachabilty来获悉网络链接是否可用。
Usage
(1) Getting connection mode 下获取到网络状态值
FBNetworkReachabilityConnectionMode mode =
[FBNetworkReachability sharedInstance].connectionMode;
switch (mode) {
case FBNetworkReachableNon:
break;
case FBNetworkReachableWiFi:
break;
case FBNetworkReachableWWAN:
break;
}
You can get the connection mode from ‘connectionMode‘ property. 你也可以从connectionMode属性值中获取到网络状态
(3) Checking reachability 检测网络是否可以连上
if ([FBNetworkReachability sharedInstance].reachable) {
:
}
You can get the rechability flag. 你可以获取到网络状态
(4) Using notification 使用通知
FBNetworkReachability posts FBNetworkReachabilityDidChangeNotification when the network reachability changs. To use the notification you can write the event driven code.