1

我必须从后台调用 sendRequest 方法。如果 sendRequest 工作完成,那么我必须在 iphone 中调用启动画面。我正在这样做,但这在 dispatch_async 中无法正常工作。我调用这个 CheckForUpdatesModal 类从后台获取所有值,然后调用视图控制器。但是如果我放断点并显示,那么它只调用 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;
    }
4

1 回答 1

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
    });
});
于 2012-07-24T12:01:45.487 回答