2010-10-20 34 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:按照您的预期正确返回。

尝试的另一件事是在应用程序启动但未启动之前打入调试器。检查回溯并确保主事件循环处于合理状态(因为它听起来好像不是)。