typedef NS_ENUM(NSInteger, BMNetworkReachabilityStatus) {
BMNetworkReachabilityStatusUnknown = -1,
BMNetworkReachabilityStatusNotReachable = 0,
BMNetworkReachabilityStatusReachableViaWWAN = 1,
BMNetworkReachabilityStatusReachableViaWiFi = 2,
BMNetworkReachabilityStatusReachableVia2G = 3,
BMNetworkReachabilityStatusReachableVia3G = 4,
BMNetworkReachabilityStatusReachableVia4G = 5,
};
- (void)dealloc{
BMRemoveNetworkStatusObserver(self);
}
- (void)viewDidLoad {
[super viewDidLoad];
BMAddNetworkStatusObserver(self);
}
#pragma mark - BMNetworkStatusProtocol
- (void)networkStatusDidChangedFromStatus:(BMNetworkReachabilityStatus)fromStatus
toStatus:(BMNetworkReachabilityStatus)toStatus{
NSLog(@"*****************************************");
if (fromStatus != toStatus) {
NSLog(@"========状态改变了啊=========");
}
NSLog(@"fromStatus: %@ toStatus: %@",@(fromStatus),@(toStatus));
NSString *statusStr = [[BMEnvObserverCenterNetworkStatus defaultCenter] currentNetWorkStatusString];
NSLog(@"当前网络状态为: %@",statusStr);
}
iJecky http://weibo.com/rubbishpicker
BMReachability is available under the MIT license. See the LICENSE file for more info.