19

IOS使用Reachability实时检测网络连接状况  

上传者:499752884

发布时间:2012-11-27 14:00:05

大小:180 K

简介://在程序的启动处,开启通知 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //..... //开启网络状况的监听 [[NSNotificationCenter defaultCenter] addObserver:self         selector:@selector(reachabilityChanged:)       name: kReachabilityChangedNotification       object: nil]; hostReach = [[Reachability reachabilityWithHostName:@"www.google.com"] retain];//可以以多种形式初始化 [hostReach startNotifier]; //开始监听,会启动一个run loop     [self updateInterfaceWithReachability: hostReach]; //..... }

ios Reachability实时检测
下 载 72人已下载
分享