<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSUserActivityRestoring/restoreUserActivityState(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSUserActivityRestoring(im)restoreUserActivityState:"
  },
  "title" : "restoreUserActivityState(_:)"
}
-->

# restoreUserActivityState(_:)

Restores the state necessary to continue the specified user activity.

```
@MainActor func restoreUserActivityState(_ userActivity: NSUserActivity)
```

## Parameters

`userActivity`

The user activity to continue.

## Discussion

Implement this method to restore an object’s state using the specified user activity. The system calls this method on any responders or documents passed to the `restorationHandler` in [`application(_:continue:restorationHandler:)`](/documentation/AppKit/NSApplicationDelegate/application(_:continue:restorationHandler:)). The system calls this method on the main thread. Your implementation should use the state data contained in the specified user activity’s <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/userInfo> dictionary to restore the object.

On macOS, the system can automatically restore activities managed by [`NSDocument`](/documentation/AppKit/NSDocument) if you don’t implement [`application(_:continue:restorationHandler:)`](/documentation/AppKit/NSApplicationDelegate/application(_:continue:restorationHandler:)), or if you return <doc://com.apple.documentation/documentation/Swift/false>. When this occurs, the system opens the document using [`openDocument(withContentsOf:display:completionHandler:)`](/documentation/AppKit/NSDocumentController/openDocument(withContentsOf:display:completionHandler:)), and calls `restoreUserActivityState` on it.

---

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)