我必须从后台调用sentRequest方法。如果sendRequest工作完成,那么我必须在iphone中调用启动画面。我这样做但这在dispatch_async中不正常。我调用这个CheckForUpdatesModal类来从后台获取所有值然后调用视图控制器。但是如果我把断点和show,那么它只调用sendrequest方法。它没有调用这种方法
-(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;
}
答案 0 :(得分: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
});
});