application(_:shouldSaveSecureApplicationState:)
Asks the delegate whether to securely preserve the app’s state.
Declaration
optional func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> BoolParameters
- application:
The singleton app object.
- coder:
A keyed archiver where you can store high-level state information. The coder’s Requiressecurecoding property is set to True, and any objects you encode must adopt Nssecurecoding.
Return Value
true to securely preserve the app’s state; otherwise, false.
Discussion
Apps must implement both this method and application(_:shouldRestoreSecureApplicationState:) for state preservation to occur.
Your implementation of this method should return true each time UIKit attempts to preserve the state of your app. You can temporarily disable state preservation by returning false, which you may want to do during testing, for example.
You can add version information or any other contextual data to the provided coder as necessary. During restoration, you can use that information to determine whether to proceed with restoring your app to its previous state. Any objects you add to the coder must adopt the NSSecureCoding protocol.
This method supersedes application(_:shouldSaveApplicationState:). If your delegate implements both methods, the system only calls this one.
See Also
Managing app state restoration
application(_:shouldRestoreSecureApplicationState:)application(_:viewControllerWithRestorationIdentifierPath:coder:)application(_:willEncodeRestorableStateWith:)application(_:didDecodeRestorableStateWith:)stateRestorationBundleVersionKeystateRestorationSystemVersionKeystateRestorationTimestampKeystateRestorationUserInterfaceIdiomKeystateRestorationViewControllerStoryboardKey