tags:

views:

35

answers:

2

Hey guys, we know that on IOS4, switch among several apps, the whole state of each app will be saved, when come back to the original app, the app will stay where it was. If user closes the app(from the app list on the bottom by double-click home button), then launch it again, the app will run from the beginning.

I'm wondering if there is a method, which can save the whole state, when user closes and launch my app, it can restore the app's state just like switching among apps.

I've checked all the method of UIApplication and it seems no such one exists. Maybe I missed it. Could anyone help me with this? Thanks in advance!

+1  A: 

Unfortunately, there is no such method as of now. The only way is to save everything to NSUserDefaults and restore using the stored data.

NSUserDefaults Class Reference

NSUserDefaults Example

Kurbz
Kurbz, thanks anyway. I wished there was a shortcut :(
+1  A: 

Not really. It would take longer than the 20s given to exit the app(at least in ios 3).

Also, if you really understand your program you will reAlize you don't need to save that much state. I save as I go, and then do lazy loading when the app starts. It is amazing how much data is never accessed again.

John Smith
Yeah, I agree with you. It's a requirement from my clients. If do so, there is too much data needed saved. It will definitely slow down my app when exiting.I think the requirement is kind of strange, as I haven't found any app doing like this.