Iphone 可达块应用

Iphone 可达块应用,iphone,ios,xcode,connection-string,reachability,Iphone,Ios,Xcode,Connection String,Reachability,在appDelegate.m中的我的应用程序中,我插入了可访问性代码,如apple所说: -(BOOL)checkInternet { Reachability *r = [Reachability reachabilityWithHostName:@"google.com"]; NetworkStatus internetStatus = [r currentReachabilityStatus]; BOOL internet; if ((internetStatus != Reachable

在appDelegate.m中的我的应用程序中,我插入了可访问性代码,如apple所说:

-(BOOL)checkInternet
{
Reachability *r = [Reachability reachabilityWithHostName:@"google.com"];
NetworkStatus internetStatus = [r currentReachabilityStatus];
BOOL internet;
if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)) {
    internet = NO;
} else {
    internet = YES;
}
return internet;
}
在我的viewcontroller.m中,方法-(void)applicationIDBecomeActive:(UIApplication*)应用程序{

gotInternet = [self checkInternet];
if ( gotInternet == 0)
{
//No connection
} else {
//Connection ok
} 
但是,当3g网络出现问题时,我的应用程序会在大约20秒后崩溃,因为延迟太多。我如何异步实现控制连接,而不使用看门狗


谢谢

请查看
NSOperation