Methods for adding objects to your state restoration archives.


protocol UIStateRestoring


You can add state restoring objects to an archive directly or by referencing them from another object that is preserved, such as a view controller. The methods of the protocol let you save enough information about the object to find or recreate it during the next launch cycle.

When adopting this protocol in your custom objects, you must also remember to register those objects using the registerObject(forStateRestoration:restorationIdentifier:) method of the UIApplication class. You do not need to register views or view controllers explicitly because UIKit registers those objects automatically. View controllers adopt this protocol so that they may be used as the restoration parent of one of your custom objects.


Accessing the Object Information

var restorationParent: UIStateRestoring?

The parent object used to scope the current object.

var objectRestorationClass: UIObjectRestoration.Type?

The class responsible for creating this object when restoring the app’s state.

Encoding and Decoding the Object

func encodeRestorableState(with: NSCoder)

Encodes state-related information for the object.

func decodeRestorableState(with: NSCoder)

Decodes and restores state-related information for the object.

func applicationFinishedRestoringState()

Called after all objects have had a chance to decode their state.


State Restoration Keys

The following keys are available in restoration archives.


Inherits From

Conforming Types

See Also

Interface Restoration

Restoring Your App’s State

Preserve and restore information related to the user’s current activities.

Preserving Your App's UI Across Launches

Return your app to its previous state after it is terminated by the system.

protocol UIViewControllerRestoration

The methods that objects adopt so that they can act as a "restoration class” for view controllers during state restoration.

protocol UIObjectRestoration

The interface that restoration classes use to restore preserved objects.