Updated 14 December 2016
In most of the time when we launch application then we have to load the images also for that application takes too much time for launching due to that reason we have to perform some task in the the background so that it will not affect foreground process.
example:
here I am giving an example of image loading and store into the cache when the application comes to background mode to foreground mode. so that whatever function you have to implement , write under the block of
1 |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{} }); |
1 2 3 4 5 6 7 8 9 10 11 12 |
- (void)applicationWillEnterForeground:(UIApplication *)application { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^{ GlobalData *obj = [GlobalData getInstance]; for(int i=0;i<[obj.categoryImages count] ; i++){ UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[obj.categoryImages objectAtIndex:i]]]]; [obj.gloablCatalogIconCache setObject:image forKey:[obj.categoryImages objectAtIndex:i]]; } }); // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.