网路状况监听
来源:互联网 发布:tensorflow 算法库 编辑:程序博客网 时间:2024/05/17 08:44
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//开启网络状况的监听
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];self.hostReach = [Reachability reachabilityWithHostName:@"www.baidu.com"] ;
[self.hostReach startNotifier];
}
//网络链接改变时会调用的方法
-(void)reachabilityChanged:(NSNotification *)note
{
Reachability *currReach = [note object];
NSParameterAssert([currReach isKindOfClass:[Reachability class]]);
//对连接改变做出响应处理动作
NetworkStatus status = [currReach currentReachabilityStatus];
//如果没有连接到网络就弹出提醒实况
self.isReachable = YES;
if(status == NotReachable)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"网络连接异常" message:@"暂无法访问信息" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
self.isReachable = NO;
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"网络连接信息" message:@"网络连接正常" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
[[NSNotificationCenter defaultCenter] postNotificationName:@"reload" object:nil];
self.isReachable = YES;
}
}
- 网路状况监听
- 网路上查询状况的指令:
- 使用广播监听网络状况
- 关于android监听网路状态的代码
- android 通过广播监听网络连接状况
- Android---动态注册监听网路变化的广播
- 状况
- 利用shell脚本监听某些远程主机的磁盘状况
- 安卓通过广播实时监听当前网络状况
- 安卓通过广播实时监听当前网络状况
- [Android初级]Android程序监听网络的连接状况,This is a demo!
- 简单的UDP监听需要打开w网路岗才能接收到数据的原因和解决办法
- 网路指令:
- 网路命令
- 网路编程
- 网路编程
- 网路连接
- 网路MTU
- 算法速成(4)队列
- 十大经典排序总结
- UnityException: Launching iOS project via Xcode failed. Check editor log for details
- finishAffinity
- sqlserver插入方法
- 网路状况监听
- ng-hide指令
- 南邮 OJ 1015 最大公约数和最小公倍数
- 你有10万粉丝又如何,然而并没有什么卵用!
- iOS开发系列--Objective-C之KVC、KVO
- 4. HTML DOM Event 对象
- ImageLoader must be init with configuration before using
- iOS开发 线程计时器
- hdu3336 KMP