Instance Method


Returns a user activity object encapsulating the current state of the specified scene.


optional func stateRestorationActivity(for scene: UIScene) -> NSUserActivity?



The scene whose state information is needed.


Use this method to return an NSUserActivity object with information about your scene's data. Save enough information to be able to retrieve that data again after UIKit disconnects and then reconnects the scene. User activity objects are meant for recording what the user was doing, so you don't need to save the state of your scene's UI.

After calling this method, and before archiving the NSUserActivity object and saving it to disk, UIKit lets you add state information in the following ways:

When reconnecting the scene later, UIKit includes the NSUserActivity object in the UIScene.ConnectionOptions passed to your scene delegate's scene(_:willConnectTo:options:) method.

See Also

Saving the State of the Scene

func scene(UIScene, didUpdate: NSUserActivity)

Tells the delegate that the specified activity object was updated.