<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/UndoManager/beginUndoGrouping()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUndoManager(im)beginUndoGrouping"
  },
  "title" : "beginUndoGrouping()"
}
-->

# beginUndoGrouping()

Marks the beginning of an undo group.

```
func beginUndoGrouping()
```

## Discussion

All individual undo operations before a subsequent [`endUndoGrouping()`](/documentation/Foundation/UndoManager/endUndoGrouping()) message are grouped together and reversed by a later [`undo()`](/documentation/Foundation/UndoManager/undo()) message. By default undo groups are begun automatically at the start of the event loop, but you can begin your own undo groups with this method, and nest them within other groups.

This method posts an [`NSUndoManagerCheckpoint`](/documentation/Foundation/NSNotification/Name-swift.struct/NSUndoManagerCheckpoint) unless a top-level undo is in progress. It posts an [`NSUndoManagerDidOpenUndoGroup`](/documentation/Foundation/NSNotification/Name-swift.struct/NSUndoManagerDidOpenUndoGroup) if a new group was successfully created.

---

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)