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

# undoManager

The undo manager for the document.

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

## Discussion

This property holds the document’s undo manager (an <doc://com.apple.documentation/documentation/Foundation/UndoManager> object). Accessing this property lazily creates a default undo manager if a custom undo manager hasn’t been set.

The undo manager for the document is registered as an observer of various <doc://com.apple.documentation/documentation/Foundation/UndoManager> notifications so that it can call [`updateChangeCount(_:)`](/documentation/UIKit/UIDocument/updateChangeCount(_:)) as the user makes undoable changes to the document. When a subclass sets this property and implements registers changes with it, it doesn’t need to call [`updateChangeCount(_:)`](/documentation/UIKit/UIDocument/updateChangeCount(_:)) directly or (more rarely) override [`hasUnsavedChanges`](/documentation/UIKit/UIDocument/hasUnsavedChanges).

---

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)