[翻译] FBNetworkReachability
FBNetworkReachability
?
?
?
You can use FBNetworkReachabilty class to get network reachability on iOS device.
你可以用FBNetworkReachabilty來獲悉網(wǎng)絡(luò)鏈接是否可用。
?
Usage
(1) Getting connection mode 下獲取到網(wǎng)絡(luò)狀態(tài)值
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屬性值中獲取到網(wǎng)絡(luò)狀態(tài)
(3) Checking reachability 檢測網(wǎng)絡(luò)是否可以連上
if ([FBNetworkReachability sharedInstance].reachable) {: }You can get the rechability flag. 你可以獲取到網(wǎng)絡(luò)狀態(tài)
(4) Using notification 使用通知
FBNetworkReachability posts FBNetworkReachabilityDidChangeNotification when the network reachability changs. To use the notification you can write the event driven code.
?
[[NSNotificationCenter defaultCenter]addObserver:selfselector:@selector(didChangeNetworkReachability:)name:FBNetworkReachabilityDidChangeNotificationobject:nil]; [[FBNetworkReachability sharedInstance] startNotifier];- (void)didChangeNetworkReachability:(NSNotification*)notification {FBNetworkReachabiity* network = [notification object];: }?
Features
- FBNetworkReachabiity does not work in background.?FBNetworkReachabiity不能在后臺運行
- FBNetworkReachabiity posts the newest network rechability change.?FBNetworkReachabiity會發(fā)送最新的網(wǎng)絡(luò)修改的狀態(tài)
- The instances has same URL points to same instance internally.?
- Thread-safe 線程安全
- Requirements: SystemConfiguration.framework 需要使用SystemConfiguration.framework框架
?
Customize
(non)
?
Installation
You should copy below files to your projects. 添加對應(yīng)的框架,然后將以下兩個文件拖到你的項目中即可
FBNetworkReachability.h FBNetworkReachability.m SystemConfiguration.framework?
License
see LICENSE file
??
轉(zhuǎn)載于:https://www.cnblogs.com/YouXianMing/p/4271568.html
總結(jié)
以上是生活随笔為你收集整理的[翻译] FBNetworkReachability的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ListItem.Update与List
- 下一篇: 创建cocos2dx lua 工程