<!--
{
  "availability" : [
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindowDelegate/windowWillReturnUndoManager(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSWindowDelegate(im)windowWillReturnUndoManager:"
  },
  "title" : "windowWillReturnUndoManager(_:)"
}
-->

# windowWillReturnUndoManager(_:)

Tells the delegate that the window’s undo manager has been requested. Returns the appropriate undo manager for the window.

```
@MainActor optional func windowWillReturnUndoManager(_ window: NSWindow) -> UndoManager?
```

## Parameters

`window`

The window whose undo manager is being requested.

## Return Value

The appropriate undo manager for the specified window.

## Discussion

If this method is not implemented by the delegate, the window creates an<doc://com.apple.documentation/documentation/Foundation/UndoManager> for `window`. Further, after a window creates its own undo manager, this method is never again called on the delegate.

---

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)