Reputation: 936
Our application takes time to resume from background in iPod, so it shows splash screen each time. When app enters foreground, it load some data from cache, if there is large amount of data it takes time. How can I handle this situation? I just put those methods into dispatch queue, but no remarkable effects.
Upvotes: 1
Views: 268
Reputation: 2017
use a dispatch queue and send those time consuming methods (methods loading data from cache) to background. and when its done, and say you need to do some UI update now, get the main queue and update the UI there
dispatch_queue_t queue = dispatch_queue_create("name for the queue", NULL);
dispatch_async(queue, ^{
//your extensive code goes here, should not involve any UI updates
//If there are any UI updates involved, uncomment the following code:
/*dispatch_async(dispatch_get_main_queue(), ^{
//UI update here, as it should always be done on main thread
});*/
});
Since you are doing heavy computing on the main thread during launch, you are being shown the splash screen. you should take care of it and move it to background, as in future, if the loading from cache takes a long time, more than 10 secs, your application will be killed by the watchdog.
Cheers, have fun
Upvotes: 1