<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSResponder/userActivity",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSResponder(py)userActivity"
  },
  "title" : "userActivity"
}
-->

# userActivity

An object encapsulating a user activity supported by this responder.

```
var userActivity: NSUserActivity? { get set }
```

## Discussion

By setting the [`userActivity`](/documentation/AppKit/NSResponder/userActivity) property on a responder, the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object becomes managed by AppKit. You should override [`updateUserActivityState(_:)`](/documentation/AppKit/NSResponder/updateUserActivityState(_:)) to write lazily any state data representing the user’s activity to the `userInfo` dictionary. AppKit automatically saves user activities it manages at appropriate times. Multiple responders can share a single <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> instance, in which case they all get a callback, such as [`updateUserActivityState(_:)`](/documentation/AppKit/NSResponder/updateUserActivityState(_:)), when the system updates the user activity object.

> Note:
> Before the update callbacks are sent, the activity object’s `userInfo` dictionary is cleared.

In macOS, <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> objects managed by [`NSResponder`](/documentation/AppKit/NSResponder) automatically <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/becomeCurrent()> based on the main window and the responder chain.

A responder object can set its [`userActivity`](/documentation/AppKit/NSResponder/userActivity) property to `nil` if it no longer wants to participate. Any <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> objects that AppKit manages but have no associated responders (or documents) are automatically invalidated.

You can use this property from any thread, and it’s key-value observable (KVO).

---

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)