标签:
/*
* 在应用委托的方法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:@"连接失败"];
}
}
标签:
原文地址:http://www.cnblogs.com/chen124/p/4422707.html