/** 在应用委托的方法didFinishLaunchingWithOptions中添加*/ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];reachability = [[Reachability reachabilityWithHostName:@"www.baidu.com"] retain];[reachability startNotifier];........return YES; /***此函数通过判断联网方式,通知给用户*/- (void)reachabilityChanged:(NSNotification *)notification{ Reachability *curReachability = [notification object]; NSParameterAssert([curReachability isKindOfClass:[Reachability class]]); NetworkStatus curStatus = [curReachability currentReachabilityStatus]; if(curStatus == NotReachable) { [DOIN_Util logFax:@"连接失败"]; }}
时间: 2024-10-13 02:18:09