<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISceneDelegate/stateRestorationActivity(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UISceneDelegate(im)stateRestorationActivityForScene:"
  },
  "title" : "stateRestorationActivity(for:)"
}
-->

# stateRestorationActivity(for:)

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

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

## Parameters

`scene`

The scene whose state information is needed.

## Discussion

Use this method to return an <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object with information about your scene’s current state. Save enough information to be able to restore that state again after UIKit disconnects and then reconnects the scene. User activity objects are a mechanism to record what the user is doing, so you don’t need to manually persist the state of your scene’s UI.

After calling this method, and before archiving the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object and saving it to disk, UIKit lets you add state information as follows:

- If you set a delegate for the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object in your app, UIKit calls the delegate’s <doc://com.apple.documentation/documentation/Foundation/NSUserActivityDelegate/userActivityWillSave(_:)> method.
- If you assign the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object to the [`userActivity`](/documentation/UIKit/UIResponder/userActivity) property of any responders, UIKit calls each responder’s [`updateUserActivityState(_:)`](/documentation/UIKit/UIResponder/updateUserActivityState(_:)) method.

When reconnecting the scene and restoring state, the user activity provided by this method will be provided in the [`stateRestorationActivity`](/documentation/UIKit/UISceneSession/stateRestorationActivity) property of [`UISceneSession`](/documentation/UIKit/UISceneSession).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)