Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

applicationWillTerminate not called when application stopped from Xcode

Tags:

xcode4

ipad

ios4

I have got into an strange issue, where the - (void)applicationWillTerminate:(UIApplication *)application{} and - (void)applicationDidEnterBackground:(UIApplication *)application{} are not called when I try to stop the application from Xcode as opposed to home button.

like image 540
Ksinak Avatar asked Feb 08 '11 18:02

Ksinak


1 Answers

This behavior is expected, because Xcode is not the home button on your iOS device.

If you click "Build and Run", for example, while testing another app, you will be prompted to kill the first app. If you do, then the first app will close as if it never opened. This seems to be a consequence of the application sandboxing.

On a similar note, If you hit the home button while testing an app on a multitasking capable device, then the app will continue to run in background mode and it will not trigger applicationWillTerminate. Your device should however, trigger applicationDidEnterBackground.

like image 51
Moshe Avatar answered Sep 28 '22 19:09

Moshe