2010-10-20 136 views
0

我在的applicationDidFinishLaunching檢查網絡的可達性:申請未能及時啓動,即使有後臺線程

[self performSelectorInBackground:@selector(performReachabilityCheck) withObject:nil]; 

後臺線程

-(void)performReachabilityCheck{ 
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
     internetReach = [[Reachability reachabilityForInternetConnection] retain]; 
     [internetReach startNotifer]; 
     [self updateInterfaceWithReachability: internetReach]; 
    [pool release]; pool = nil; 
} 

我不知道爲什麼我的應用程序啓動失敗及時?

+0

這樣做的另一種方法:http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk/3597085#3597085 – iwasrobbed 2010-10-20 19:03:31

回答

0

是否[self updateInterfaceWithReachability: internetReach];正確更新主線程中的UI?如果不是,那可能是一個問題。

否則,我建議您確保您的applicationDidFinishLaunching:按照您的預期正確返回。

嘗試的另一件事是在應用程序啓動但未啓動之前打入調試器。檢查回溯並確保主事件循環處於合理狀態(因爲它聽起來好像不是)。