In iOS 4.0 and later, - (void)applicationDidEnterBackground:(UIApplication *)application
method is called instead of the applicationWillTerminate:
method when the user quits an application that supports background execution.
You should use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
You should also disable updates to your application’s user interface and avoid using some types of shared system resources (such as the user’s contacts database). It is also imperative that you avoid using OpenGL ES in the background.
Your implementation of this method has approximately five seconds to perform any tasks and return. If you need additional time to perform any final tasks, you can request additional execution time from the system by calling beginBackgroundTaskWithExpirationHandler:
. In practice, you should return from applicationDidEnterBackground:
as quickly as possible. If the method does not return before time runs out your application is terminated and purged from memory.