Instance Method


Tells your delegate to save any high-level state information at the beginning of the state preservation process.


- (void)application:(UIApplication *)application willEncodeRestorableStateWithCoder:(NSCoder *)coder;



Your singleton app object.


The keyed archiver in which to write any state information.


The state preservation system calls this method at the beginning of the preservation process. This is your opportunity to add any app-level information to state information. For example, you might use this method to write version information or the high-level configuration of your app.

Your implementation of this method can encode restorable view and view controller objects that it needs to reference. Encoding a restorable view or view controller writes that object’s restoration identifier to the coder. (That identifier is used during the decode process to locate the new version of the object.) If the view or view controller defines a encodeRestorableStateWithCoder: method, that method is also called at some point so that the object can encode its own state.

Apart from views and view controllers, other objects follow the normal serialization process and must adopt the NSCoding protocol before they can be encoded. Encoding such objects embeds the object’s contents in the archive directly. During the decode process, a new object is created and initialized with the data from the archive.

See Also

Managing App State Restoration

- application:shouldSaveApplicationState:

Asks the delegate whether the app’s state should be preserved.

- application:shouldRestoreApplicationState:

Asks the delegate whether the app’s saved state information should be restored.

- application:viewControllerWithRestorationIdentifierPath:coder:

Asks the delegate to provide the specified view controller.

- application:didDecodeRestorableStateWithCoder:

Tells your delegate to restore any high-level state information as part of the state restoration process.


The version of your app responsible for creating the restoration archive.


The version of the system on which your app created the restoration archive.


The time at which your app created the restoration archive.


The user interface idiom that was in effect when your app created the restoration archive.


A reference to the storyboard that contains the view controller.