<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDocument/userActivity",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIDocument(py)userActivity"
  },
  "title" : "userActivity"
}
-->

# userActivity

An object encapsulating a user activity supported by this document.

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

## Discussion

[`UIDocument`](/documentation/UIKit/UIDocument) automatically creates <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> objects. The system makes user activities eligible for Handoff if the document is iCloud-based and the app’s `Info.plist` property list file includes a <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/CFBundleDocumentTypes> key of `NSUbiquitousDocumentUserActivityType`. The value of `NSUbiquitousDocumentUserActivityType` is a string that represents the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object’s activity type. The document’s URL is in the <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object’s <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/userInfo> dictionary with the [`userActivityURLKey`](/documentation/UIKit/UIDocument/userActivityURLKey).

In iOS, to make an  <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object that UIKit manages current, you must either call <doc://com.apple.documentation/documentation/Foundation/NSUserActivity/becomeCurrent()> explicitly or have the document’s <doc://com.apple.documentation/documentation/Foundation/NSUserActivity> object also set on a [`UIViewController`](/documentation/UIKit/UIViewController) object that’s in the view hierarchy when the app comes to the foreground.

You can use this property from any thread. It’s KVO-observable in case you share the [`userActivity`](/documentation/UIKit/UIDocument/userActivity) object with other objects that need to be kept in sync as the document moves into and out of iCloud.

---

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)