<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIResponder/userActivity",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIResponder(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/UIKit/UIResponder/userActivity) property on a responder, the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object becomes managed by UIKit. User activities managed by UIKit are saved automatically at appropriate times. You can lazily add state data representing the user’s activity using the [`updateUserActivityState(_:)`](/documentation/UIKit/UIResponder/updateUserActivityState(_:)) override. Multiple responders can share a single <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> instance, in which case they all get an [`updateUserActivityState(_:)`](/documentation/UIKit/UIResponder/updateUserActivityState(_:)) callback.

> Note:
> Prior to invoking ``doc://com.apple.uikit/documentation/UIKit/UIResponder/updateUserActivityState(_:)`` on all of the associated objects, the `userInfo` dictionary for the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object is cleared.

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

---

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)