首页 > 其他 > 详细

Reachability(判断网络是否连接)

时间:2015-04-13 18:29:50      阅读:198      评论:0      收藏:0      [点我收藏+]
/*
* 在应用委托的方法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:@"连接失败"];
}
}

Reachability(判断网络是否连接)

原文:http://www.cnblogs.com/chen124/p/4422707.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!