---
title: levelsOfUndo
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/undomanager/levelsofundo
---

# levelsOfUndo

The maximum number of top-level undo groups the undo manager holds.

## Declaration

```swift
var levelsOfUndo: Int { get set }
```

## Discussion

Discussion An integer specifying the number of undo groups. A limit of 0 indicates no limit, so the manager never drops old undo groups. When ending an undo group results in the number of groups exceeding this limit, the manager drops the oldest groups from the stack. The default is 0. If you change the limit to a level below the prior limit, the manager immediately drops old undo groups.

## See Also

### Related Documentation

- [enableUndoRegistration()](foundation/undomanager/enableundoregistration().md)

### Managing undo and redo stack depth

- [undoCount](foundation/undomanager/undocount.md)
- [redoCount](foundation/undomanager/redocount.md)
