Over a million developers have joined DZone.

Tutorial: State Preservation and Restoration

DZone 's Guide to

Tutorial: State Preservation and Restoration

· Mobile Zone ·
Free Resource

If you’re like us and have been putting off puzzling out the State Preservation and Restoration stuff more or less indefinitely, here’s a great introduction to get you started on that:

State Preservation and Restoration

From the very first releases of the iPhone SDK Apple has encouraged developers to think about app startup and switching to make the experience as quick and transparent as possible for the user. The limited resources of mobile devices mean that App termination is a common occurrence. Returning to a previously running App that has been terminated by the system and finding it back at a startup screen is not a great user experience. The ability for an App to be suspended and resumed was introduced with iOS 4 and helps to reduce the problem but to make App termination transparent to the end user still takes developer effort.

There is a non-trivial amount of work required to save and then restore a deeply nested hierarchy of views and view controllers. Luckily with iOS 6 direct UIKit support for state preservation and restoration was introduced. This post is a collection of my notes on the basic steps to implement state preservation and restoration…

Supporting project at CodeExamples / Restorer for that and the followup

Restoration Classes and UIWebViews

I previously covered the basics of using state preservation and restoration but for the sake of brevity I did not provide an example of how to use a Restoration Class. This post will fix that omission and also take a look at how you can implement state restoration for a UIWebView…

Also note the current need to force reload tables, discussed here:

Bug Table View State Not Restored When Embedded in Navigation Controller

And there’s some extra nuggets to be gleaned here:

iOS State Preservation and Restoration

There, that should help you catch up with that new iOS 6 stuff just in time for iOS 7 to snow us completely under again!

h/t: iOS Dev Weekly!


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}