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

# UIManagedDocument

A managed document object that integrates with Core Data.

```
@MainActor class UIManagedDocument
```

## Overview

[`UIManagedDocument`](/documentation/UIKit/UIManagedDocument) is a concrete subclass of [`UIDocument`](/documentation/UIKit/UIDocument). When you initialize a managed document, you specify the URL for the document location. The document object then creates a Core Data stack to use to access the document’s persistent store using a managed object model from the app’s main bundle. [`UIManagedDocument`](/documentation/UIKit/UIManagedDocument) performs all the basic setup you need for Core Data, and in some cases you may use instances of the class directly (without a need to subclass). You can supply configuration options for the creation of the coordinator using [`persistentStoreOptions`](/documentation/UIKit/UIManagedDocument/persistentStoreOptions), and for the model using [`modelConfiguration`](/documentation/UIKit/UIManagedDocument/modelConfiguration). You can also perform additional customization by creating a subclass of [`UIManagedDocument`](/documentation/UIKit/UIManagedDocument):

- Override [`persistentStoreName`](/documentation/UIKit/UIManagedDocument/persistentStoreName) to customize the name of the persistent store file inside the document’s file package.
- Override [`managedObjectModel`](/documentation/UIKit/UIManagedDocument/managedObjectModel) to customize creation of the managed object model.

You do this if, for example, your app supports multiple document types, each of which uses a different model. You want to ensure that the models aren’t merged for each document class.

- Override [`persistentStoreType(forFileType:)`](/documentation/UIKit/UIManagedDocument/persistentStoreType(forFileType:)) to customize the type of persistent store used by a document.
- Override [`configurePersistentStoreCoordinator(for:ofType:modelConfiguration:storeOptions:)`](/documentation/UIKit/UIManagedDocument/configurePersistentStoreCoordinator(for:ofType:modelConfiguration:storeOptions:)) to customize the loading or creation of a persistent store.

### Handling errors

To enable your app to observe and handle errors in saving and validating a managed document, you must subclass the [`UIManagedDocument`](/documentation/UIKit/UIManagedDocument) class and override one or both of the following two inherited methods from the [`UIDocument`](/documentation/UIKit/UIDocument) class:

- [`handleError(_:userInteractionPermitted:)`](/documentation/UIKit/UIDocument/handleError(_:userInteractionPermitted:))
- [`finishedHandlingError(_:recovered:)`](/documentation/UIKit/UIDocument/finishedHandlingError(_:recovered:))

Overriding is required because otherwise, the only information your app receives on error is the [`stateChangedNotification`](/documentation/UIKit/UIDocument/stateChangedNotification) notification, which doesn’t contain a `userInfo` dictionary and so doesn’t convey specific error information.

## Topics

### Managing the Core Data stack

[`-  configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:`](/documentation/UIKit/UIManagedDocument/configurePersistentStoreCoordinator(for:ofType:modelConfiguration:storeOptions:))

Creates or loads the document’s persistent store.

[`managedObjectContext`](/documentation/UIKit/UIManagedDocument/managedObjectContext)

The document’s managed object context.

[`managedObjectModel`](/documentation/UIKit/UIManagedDocument/managedObjectModel)

The document’s managed object model.

[`persistentStoreOptions`](/documentation/UIKit/UIManagedDocument/persistentStoreOptions)

Options used when creating the document’s persistent store.

[`modelConfiguration`](/documentation/UIKit/UIManagedDocument/modelConfiguration)

A model configuration name to be passed when configuring the persistent store.

[`-  persistentStoreTypeForFileType:`](/documentation/UIKit/UIManagedDocument/persistentStoreType(forFileType:))

Returns the Core Data store type for a given document file type.

### Customizing read and write operations

[`-  readAdditionalContentFromURL:error:`](/documentation/UIKit/UIManagedDocument/readAdditionalContent(from:))

Handles reading non-Core Data content in the additional content directory in the document’s file package.

[`-  additionalContentForURL:error:`](/documentation/UIKit/UIManagedDocument/additionalContent(for:))

Handles writing non-Core Data content to the additional content directory in the document’s file package.

[`-  writeAdditionalContent:toURL:originalContentsURL:error:`](/documentation/UIKit/UIManagedDocument/writeAdditionalContent(_:to:originalContentsURL:))

Handles writing non-Core Data content to the document’s file package.

### Naming the persistent store file

[`persistentStoreName`](/documentation/UIKit/UIManagedDocument/persistentStoreName)

Returns the name for the persistent store file inside the document’s file package.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

[`ProgressReporting`](/documentation/Foundation/ProgressReporting)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`UIUserActivityRestoring`](/documentation/UIKit/UIUserActivityRestoring)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`UINavigationItemRenameDelegate-96g5t`](/documentation/UIKit/UINavigationItemRenameDelegate-96g5t)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSFilePresenter`](/documentation/Foundation/NSFilePresenter)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

### Inherits From

[`UIDocument`](/documentation/UIKit/UIDocument)

---

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)