我要檢查一個有效的網絡連接。我跟着蘋果的可達性例子,把我的支票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的問題在這裏:Application Failed to Launch in Time
我不確定我應該在哪裏執行可達性檢查?
爲什麼我不能把它放在ApplicationDidFinishLaunching中? – 2010-10-17 17:48:44
每次應用程序激活時你都不想測試它嗎?使用iOS 4多任務處理可能會發生很多事情。 – asandroq 2010-10-18 01:54:51