- (void)addReachability {
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(reachabilityChanged:)name:kReachabilityChangedNotificationobject:nil];
[[ReachabilityreachabilityForInternetConnection]startNotifier];
[selfupdateInterfaceWithReachability:[ReachabilityreachabilityForInternetConnection]];
}
- (void)reachabilityChanged:(NSNotification*)notification {
NSParameterAssert([[notificationobject]isKindOfClass:[Reachabilityclass]]);
[selfupdateInterfaceWithReachability:[notificationobject]];
}
- (void)dealloc {
[[NSNotificationCenterdefaultCenter]removeObserver:selfname:kReachabilityChangedNotificationobject:nil];
}
- (void)updateInterfaceWithReachability:(Reachability*)reachability {
if([reachabilitycurrentReachabilityStatus] ==NotReachable) {
[XLxl_showTipText:@"沒有網(wǎng)絡(luò)"];
}elseif([reachabilitycurrentReachabilityStatus] ==ReachableViaWiFi) {
[XLxl_showTipText:@"WiFi"];
}else{
[XLxl_showTipText:@"蜂窩"];
}
}