2012年4月29日 星期日

[iOS] Catch application end

Sometime we always want to catch the application terminate in mobile platform.

In iDevice, we can use
 - (void)applicationWillTerminate:(UIApplication *)application
to catch the terminate action.

But since iOS 4.0, application will goes to background instead of being killed when you press the home button.
If you are doing so,  
- (void)applicationWillTerminate:(UIApplication *)application 
might not be called.

From apple developer's guide,UIApplicationDelegate Protocol Reference 
- (void)applicationDidEnterBackground:(UIApplication *)application 
will be called instead.
 
When you goes to background, and kill the app bu double click the home button and click the red cross,
 - (void)applicationWillTerminate:(UIApplication *)application 

will still being called. But if it died naturally, then it won't be called.

沒有留言:

張貼留言