2012-07-24 42 views
1

我必须从后台调用sentRequest方法。如果sendRequest工作完成,那么我必须在iphone中调用闪屏。我正在这样做,但这在dispatch_async中无法正常工作。我打电话给这个CheckForUpdatesModal类从后台获取所有的值,然后调用视图控制器。但是,如果我把断点和显示,那么它只调用sendrequest方法。它不调用此方法如何在应用程序iphone的后台调用方法?

-(void)connectionDidFinishLoading:(NSURLConnection *)connection pleasehelp me here what is wrong some give me this ans to follow dispatch and my xcode version is4.2 
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 


             [BaseModalcopyDatabaseIfNeeded]; 
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ 
      NSLog(@"pradeep"); // Here you can define your code to execute in background.}); 

      CheckForUpdatesModal *CFUM = [[CheckForUpdatesModal alloc]init]; 
      [CFUM sendRequest]; 
      [CFUM release]; 


     }); 

      self.SSView = [[[SplashScreenView alloc] initWithNibName:@"SplashScreenView" bundle:nil] autorelease];   
      self.window.rootViewController = SSView; 
      [self.window makeKeyAndVisible]; 
      return YES; 
    } 

回答

2

试试这个: -

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); 

dispatch_async(queue, ^{ 
     CheckForUpdatesModal *CFUM = [[CheckForUpdatesModal alloc]init]; 
     [CFUM sendRequest]; 
     [CFUM release]; 

    dispatch_sync(dispatch_get_main_queue(), ^{ 
     //SHOW UR SPLASH SCREEN HERE 
    }); 
}); 
相关问题