best practice for saving state when app enters background?

This seems like something that would be in the forum already, but I couldn’t find it…

Can someone suggest the best way to save/restore the state of an app when it enters the background/is relaunched?

Did you look into NSUserDefaults? It is a very simple interface for saving data, intended for things like preferences (it’s objective-c though, I don’t know if that’s a problem).

What about getting alerts when the app enters the background? It seems that I need to add “applicationDidEnterBackground:” and “applicationWillEnterForeground:” to ofxiPhoneAppDelegate, no?

Is there a way to do this without editing the addon?

For anyone else who has this problem, the first thing you’ll want to do is open the “ofxiphone-Info.plist” in your project and set “Application does not run in background” to “NO”. This will at least make it so that the app doesn’t completely restart every time it goes into the background.

1 Like