---
title: undoManager
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uidocument/undomanager
---

# undoManager

The undo manager for the document.

## Declaration

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

## Discussion

Discussion This property holds the document’s undo manager (an 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 UndoManager notifications so that it can call 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(_:) directly or (more rarely) override hasUnsavedChanges.

## See Also

### Tracking changes and autosaving

- [hasUnsavedChanges](uikit/uidocument/hasunsavedchanges.md)
- [updateChangeCount(_:)](uikit/uidocument/updatechangecount(_:).md)
- [changeCountToken(for:)](uikit/uidocument/changecounttoken(for:).md)
- [updateChangeCount(withToken:for:)](uikit/uidocument/updatechangecount(withtoken:for:).md)
- [autosave(completionHandler:)](uikit/uidocument/autosave(completionhandler:).md)
