Instance Method

application(_:shouldRestoreApplicationState:)

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

Declaration

optional func application(_ application: UIApplication, shouldRestoreApplicationState coder: NSCoder) -> Bool

Parameters

application

Your singleton app object.

coder

The keyed archiver containing the app’s previously saved state information.

Return Value

true if the app’s state should be restored or false if it should not.

Discussion

Apps must implement this method and the application(_:shouldSaveApplicationState:) method for state preservation to occur. In addition, your implementation of this method must return true each time UIKit tries to restore the state of your app. You can use the information in the provided coder object to decide whether or not to proceed with state restoration. For example, you might return false if the data in the coder is from a different version of your app and cannot be effectively restored to the current version.

See Also

Managing App State Restoration

func application(UIApplication, shouldSaveApplicationState: NSCoder) -> Bool

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

func application(UIApplication, willEncodeRestorableStateWith: NSCoder)

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

func application(UIApplication, didDecodeRestorableStateWith: NSCoder)

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

class let stateRestorationBundleVersionKey: String

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

class let stateRestorationSystemVersionKey: String

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

class let stateRestorationTimestampKey: String

The time at which your app created the restoration archive.

class let stateRestorationUserInterfaceIdiomKey: String

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

class let stateRestorationViewControllerStoryboardKey: String

A reference to the storyboard that contains the view controller.