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.
Asked
Active
Viewed 4,027 times
7
-
1This behavior makes sense, because Xcode is *not* the home button. – Moshe Feb 08 '11 at 18:48
-
I am trying to simulate a situation where i need to perform file actions when i get to applicationWillTerminate. When i stop the running application it does not call applicationWillTerminate, is it because it terminates the app running. – Ksinak Feb 08 '11 at 19:08
-
@moshe : Thanks. I think i understand now that since closing the running app from the xcode, kills the whole app and hence there is no further call. – Ksinak Feb 08 '11 at 19:12
-
I will post an answer. You should select some answers if they've helped you, so that people will be motivated to help you. – Moshe Feb 08 '11 at 19:13
-
Possible duplicate of [Why doesn’t stopping an application in iOS simulator trigger applicationWillTerminate:?](https://stackoverflow.com/questions/14079670/why-doesn-t-stopping-an-application-in-ios-simulator-trigger-applicationwillterm). This is an older quesiton, but both answers on this and the duplicate question are good... I though the other answer is better. – mfaani Oct 26 '17 at 17:58
1 Answers
11
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
.

Moshe
- 57,511
- 78
- 272
- 425
-
Thanks for the insight !!! Yup i faced the same issue with my app in multitasking and i had to override applicationDidEnterBackground in addition to applicationWillTerminate. This answers my doubt. – Ksinak Feb 08 '11 at 20:16