我想检查有效的网络连接。我按照 Apple 的 Reachability 示例并签入applicationDidFinishLaunching
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if(getenv("NSZombieEnabled") || getenv("NSAutoreleaseFreedObjectCheckEnabled"))
{
NSLog(@"NSZombieEnabled/NSAutoreleaseFreedObjectCheckEnabled enabled!");
}
// Override point for customization after application launch.
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];
//Check for connectivity
internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifer];
[self updateInterfaceWithReachability: internetReach];
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
但是,我的应用程序有时会因错误而崩溃Application Failed to Launch in Time
我在这里发布了我的崩溃作为一个 SO 问题:应用程序无法及时启动
我不确定我应该在哪里执行可达性检查?