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

# updateUserActivityState(_:)

Updates the state of the given user activity.

```
func updateUserActivityState(_ activity: NSUserActivity)
```

## Parameters

`activity`

The user activity to be updated.

## Discussion

The default implementation of this method puts the document’s [`fileURL`](/documentation/AppKit/NSDocument/fileURL) into the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object’s <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/userInfo> dictionary with the [`NSUserActivityDocumentURLKey`](/documentation/AppKit/NSUserActivityDocumentURLKey). [`NSDocument`](/documentation/AppKit/NSDocument) automatically sets the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/needsSave> property of the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> to <doc://com.apple.documentation/documentation/Swift/true> when the [`fileURL`](/documentation/AppKit/NSDocument/fileURL) changes.

## See Also

[`NSDocument`](/documentation/AppKit/NSDocument)

An abstract class that defines the interface for macOS documents.



---

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)