【发布时间】:2010-10-17 14:54:07
【问题描述】:
我想检查有效的网络连接。我遵循了 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
我在这里发布了我的崩溃问题:Application Failed to Launch in Time
我不确定应该在哪里执行可达性检查?
【问题讨论】:
标签: iphone objective-c cocoa-touch ios reachability