1

Any one have good strategies on how to deal with state restoration and preservation when your app relies on lots of data from a server and the data may change significantly between app runs?

I watched the video WWDC 2012-Session 208 which talks about state preservation and restoration and I do understand that you're saving and restoring your app's View Controllers and not the data model used by your app.

But when what your view controllers display is very much linked to the data that you receive from a service, some of which are either stale or no longer exists since your app shut down and relaunch, you can't save the object's id and hope to redisplay it at a later time.

Most of the sample apps I've come across seem to cover the simple version where app data is fairly static and doesn't seem to come from a service.

My questions are: 1) What are the gotchas and other caveats one must consider for a client/server style app?

2) With the caveats considered, where in the app would you initiate the call to the remote services to refresh of data?

Paul Hansen
  • 153
  • 2
  • 12
  • You must have some idea of how fast your data ages. Make sure you know the last time your app was running. If the next launch is within some small time period, assume the data you have is good and go back to where you were. If its a bit stale, pop a spinner and tell the user you are updating. If its been a really long time wipe the data and start fresh. – David H May 31 '13 at 20:06
  • When is the best time to initiate a data fetch from the servers during restoration? – Paul Hansen May 31 '13 at 20:34
  • I think we'll need a more specific question to answer this. Describe the data. Why wouldn't you just poll the system for live data for each view? – Marcus Adams May 31 '13 at 20:47
  • I want to bring them back to the same screen they were on, on app resume/restore. But the state of the world has changed. As an example, a Calendar app may have new events and you left off in a List screen that showed say 3 events. After restore, you now have 15 new events. I'd like to show the same screen that you were previously on before the app suspend but with the new changes. I am not sure where the data fetch should be invoked to handle state preservation and restoration. – Paul Hansen May 31 '13 at 21:23

0 Answers0