How do I force the app to always start from scratch when it comes back from the background?
If your goal is to restart your application from scratch on every start, just add / change the key UIApplicationExitsOnSuspend
to YES
in info.plist file
Here's the relevant link in the documentation http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html
source to share
One option is to use exit()
. However, this method is only useful for testing / programming. Apple will not agree that you are in your code.
Another option is to create a global session similar to the method used by most social media APIs and in your app delegate section:
- (void)applicationDidEnterBackground:(UIApplication *)application
set the global session private. Then just set the protocol logic to restart if the session is closed.
I hope this helps!
source to share