---
title: "updateUserActivityState(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocument/updateuseractivitystate(_:)"
---

# updateUserActivityState(_:)

Updates the state of the given user activity.

## Declaration

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

## Parameters

- `activity`: The user activity to be updated.

## Discussion

Discussion The default implementation of this method puts the document’s fileURL into the NSUserActivity object’s userInfo dictionary with the NSUserActivityDocumentURLKey. NSDocument automatically sets the needsSave property of the NSUserActivity to true when the fileURL changes.

## See Also

### Related Documentation

- [NSDocument](appkit/nsdocument.md)

### Supporting User Activities

- [userActivity](appkit/nsdocument/useractivity.md)
- [NSUserActivityDocumentURLKey](appkit/nsuseractivitydocumenturlkey.md)
