Eric Brotto
Eric Brotto

Reputation: 54281

Is there a catch all method one could use to reset iPhone app when user exits?

Just wondering:

Basically my app runs fine until the user exits and then tries to go back in. My app doesn't involve anything to be saved or stored for the future. It would be great if there was a method that when the user exited (when they hit the physical exit button) the app was just cleared out and was ready to be launched again as if nothing had every happened.

Any ideas?

Thanks,

Upvotes: 2

Views: 181

Answers (2)

Christian
Christian

Reputation: 1714

There is no way to really do this, but you could feign it by putting some logic in your AppDelegate's applicationWillEnterForeground: method. In this method, you would just do any necessary steps to reset the application back to an initial state.

Upvotes: 0

BoltClock
BoltClock

Reputation: 724352

Assuming you've made sure your application doesn't persist anything, all you have left to do is add UIApplicationExitsOnSuspend and set it to true in your application's Info.plist. The moment the user leaves your application, its process will terminate. When the user starts your application again it won't remember anything; it'll just start from the beginning. This includes displaying the launch image.

Upvotes: 3

Related Questions