测试网络连接
测试网络连接
BOOL hasInet; Reachability *connectionMonitor = [Reachability reachabilityForInternetConnection]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(inetAvailabilityChanged:) name: kReachabilityChangedNotification object: connectionMonitor]; hasInet = [connectionMonitor currentReachabilityStatus] != NotReachable;
-(void)inetAvailabilityChanged:(NSNotification *)notice { Reachability *r = (Reachability *)[notice object]; hasInet = [r currentReachabilityStatus] != NotReachable; }