SnapReachability
示例
要运行示例项目,请克隆仓库,并首先从示例目录中运行pod install
需求
安装
SnapReachability可通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中
pod 'SnapReachability'
使用方法
import SnapReachability
...
//start listening for network events
ReachabilityManager.shared.stopMonitoring()
ReachabilityManager.shared.addListener(listener: self)
//stop listening for networl events
ReachabilityManager.shared.stopMonitoring()
ReachabilityManager.shared.removeListener(listener: self)
//implement NetworkStatusListnerProtocol
extension YouClas: NetworkStatusListener{
switch reachability.connection {
case .unavailable:
debugPrint("Network became unreachable")
case .wifi:
debugPrint("Network reachable through WiFi")
case .cellular:
debugPrint("Network reachable through Cellular Data")
case .none:
debugPrint("Unkown netwoprk status")
}
}
作者
DominatorVbN, [email protected]
许可证
SnapReachability可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。