UHBConnectivity 管理器是 Reachability 上的Objective-C 封装。您可以通过块来观察网络变化。
您可以使用唯一标识符注册任何对象
[[UHBConnectivityManager shared] registerCallBack:^(ConnectivityManagerConnectionStatus status) {
if (status == ConnectivityManagerConnectionStatusConnected) {
// Device connected to internet: You may update your data here
}
else
{
// Show alert
}
} forIdentifier:self.memoryAddress];
您可以在 dealloc 方法或任何您想要的地方取消注册回调。
[[UHBConnectivityManager shared] removeCallBackForIdentitfier:self.memoryAddress];
iOS 版本 7.0 或更高
UHBConnectivityManager 通过 CocoaPods 提供。要安装它,请简单地将以下行添加到您的 Podfile 中
pod "UHBConnectivityManager"
Umair Hassan Baig, [email protected]
UHBConnectivityManager 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。