views:

52

answers:

3

is there a way to restore an app to the original settings when a user exits?

I need the app the reset every time it's closed out.

thanks so much.

A: 

You can use this method application:didFinishLaunchingWithOptions:

KiranThorat
like applicationWillTerminate: maybe? the documentation says that: This method lets your application know that it is about to be terminated and purged from memory entirely.that sounds right.
hanumanDev
You can use applicationWillTerminate it's a small time window you have to do all your work... at the same time.. application:didFinishLaunching also has limited time else your application will force to quit..
KiranThorat
his program will neither reach applicationWillTerminate nor application:didFinishLaunching. It just moves to the background, and if it comes to the foreground it looks like when he did "exit" the app.
fluchtpunkt
In that case you can use applicationDidEnterBackground, applicationWillEnterForeground.. But I don't see why it wont exit.. you can add UIApplicationExitsOnSuspend in info.plist to exit app..
KiranThorat
+1  A: 

If you don't want to keep data after the application end just don't save it. Nothing is saved automatically for you.

Don't use NSUserDefaults, CoreData and don't store things on the filesystem.

fluchtpunkt
I'm not CoreData or storing on the filesystem. I just want the the first tabcontroller view to be displayed and the animations to start over.
hanumanDev
so I guess your app was in the background.
fluchtpunkt
it should show the first tabcontroller ... add UIApplicationExitsOnSuspend inside the info.plist
KiranThorat
thanks, I'll try that. at the moment it gets stuck at the point where the user leaves the app (normally I would want this, but not in this case).
hanumanDev
that worked. I checked the "Application does not run in background" in the info.plistthanks everyone for the help.
hanumanDev
+3  A: 

Add the UIApplicationExitsOnSuspend key to your app's info.plist. This will cause your app to terminate when the user hits the button. Then don't load anything saved from NSDefaults (etc.) when your app restarts.

hotpaw2
This is the best answer and all these other answers are ridiculous.
Jasconius
I agree, best answer. iPhone 4 defaults to multi-tasking so it will run where it last left off. Don't let the development version of your app fool you though... sometimes it will continue where it left off despite adding the UIApplicationExitsOnSuspend key... especially in the Simulator.
Jamie Chapman