---
title: userActivity
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uiresponder/useractivity
---

# userActivity

An object encapsulating a user activity supported by this responder.

## Declaration

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

## Discussion

Discussion By setting the userActivity property on a responder, the 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(_:) override. Multiple responders can share a single NSUserActivity instance, in which case they all get an updateUserActivityState(_:) callback. note: Prior to invoking updateUserActivityState(_:) on all of the associated objects, the userInfo dictionary for the NSUserActivity object is cleared. A responder object can set its userActivity property to nil if it no longer wants to participate. Any NSUserActivity objects that are managed by UIKit but which have no associated responders (or documents) are automatically invalidated.

## See Also

### Supporting user activities

- [restoreUserActivityState(_:)](uikit/uiresponder/restoreuseractivitystate(_:).md)
- [updateUserActivityState(_:)](uikit/uiresponder/updateuseractivitystate(_:).md)
