---
title: endUndoGrouping()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/undomanager/endundogrouping()
---

# endUndoGrouping()

Marks the end of an undo group.

## Declaration

```swift
func endUndoGrouping()
```

## Discussion

Discussion All individual undo operations back to the matching beginUndoGrouping() message are grouped together and reversed by a later undo() or undoNestedGroup() message. Undo groups can be nested, thus providing functionality similar to nested transactions. Raises an NSInternalInconsistencyException if there’s no beginUndoGrouping() message in effect. This method posts an NSUndoManagerCheckpoint and an NSUndoManagerDidCloseUndoGroup just before the group is closed.

## See Also

### Related Documentation

- [levelsOfUndo](foundation/undomanager/levelsofundo.md)

### Creating undo groups

- [beginUndoGrouping()](foundation/undomanager/beginundogrouping().md)
- [groupsByEvent](foundation/undomanager/groupsbyevent.md)
- [groupingLevel](foundation/undomanager/groupinglevel.md)
