Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How exactly does applicationWillTerminate work on iPhone?

Tags:

iphone

I'm considering how to make my iPhone application as "bullet proof" as possible.

Right now, I'm thinking about how the app will respond to the user hitting the home button at a critical point in the application's processing.

What exactly happens? Are any more instructions executed in the application's threads?

When applicationWillTerminate gets called, I've read that the application "has a few seconds before the os kills the process" - again, what exactly happens?

like image 308
Alan Avatar asked Jan 20 '09 04:01

Alan


2 Answers

What I've observed is that the home screen appears immediately, but the app is allowed to continue running in the background for at least a few seconds. If it takes too long, it will get killed.

like image 131
Chris Lundie Avatar answered Sep 25 '22 22:09

Chris Lundie


applicationWillTerminate is called when your application exits due to a call a user decides to take or when the OS kills it due to some other reason. You cannot stop the app from being terminated but can store some data which you want to use later in this method.

For instance if your app lets the user search for something, you can save the search term when the app is about to terminate (in applicationWillTerminate) method so you can use it later when the user logs in to the app again.

So the implementation of the method depends on what you want your app to do when the user decides to quit the app or the OS kills it.

like image 45
lostInTransit Avatar answered Sep 22 '22 22:09

lostInTransit