<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "swift: 5.9.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftData",
  "identifier" : "/documentation/SwiftData/ModelContext/undoManager",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData12ModelContextC11undoManagerSo06NSUndoF0CSgvp"
  },
  "title" : "undoManager"
}
-->

# undoManager

The object that provides undo support for the context.

```
var undoManager: UndoManager? { get set }
```

## Discussion

Assign an instance of <doc://com.apple.documentation/documentation/Foundation/UndoManager>
to this property to enable undo support for the context. The undo manager can
be exclusive to the context, or an existing manager should you want to
integrate this context’s undo operations with those of the rest of your app.

If the context does use an undo manager, improve performance by temporarily
setting this property to `nil` when performing expensive operations, such as
importing large numbers of models.

The default value is `nil`.

---

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)