I getting a little confused about when one needs to save state for an iPhone app. In particular for the scenario where one’s Iphone IOS version supports multitasking, and when you come back to it, it does appear to be in the same state (for my simple app anyway).
Question – Can you clarify how the “need to save state for an iPhone app”, and the multitasking support play together.
Hopefully the response can help clarify aspects such as:
-
For the multitasking support scenario (when a user doesn’t explicitly terminate the application), is there any need at all to save state? Or does IOS do it for you (which it kind of appears it does for my simple app).
-
If the answer to 1 is YES, then at what point do you really need to save state then?
-
If the answer to 1 is NO, then exactly what data/state do you lose versus not-lose when IOS does keep your application “running” in the background?
thanks
1A. Yes. Because…
1B. You don’t know. The OS usually saves state on newer devices, but this is not guaranteed, and will not always happen. On older devices the OS won’t save state.
2A. Even if the answer to 1B. is YES, the OS could still delete your app’s state to save memory. So you still need to save any state you don’t want potentially lost after your app is suspended.
3A. Your app may lose track of time (from NSTimer ticks, etc.) if it doesn’t check the clock on resume.