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

# addWindowController(_:)

Adds the specified window controller to the current document.

```
func addWindowController(_ windowController: NSWindowController)
```

## Parameters

`windowController`

The window controller that is added.

## Discussion

An [`NSDocument`](/documentation/AppKit/NSDocument) object uses its list of window controllers when it displays all document windows, sets window edited status upon an undo or redo operation, and modifies window titles. If you create window controllers by overriding [`windowNibName`](/documentation/AppKit/NSDocument/windowNibName), this method is invoked automatically. If you create window controllers in [`makeWindowControllers()`](/documentation/AppKit/NSDocument/makeWindowControllers()) or in any other context, such as in apps that present multiple windows per document, you should invoke this method for each window controller created.

You cannot attach a window controller to more than one document at a time. The default implementation of this method removes the passed-in window controller from the document to which it is attached, if it is already attached to one, then sends it a [`document`](/documentation/AppKit/NSWindowController/document) message with `self` as the argument. It also ignores redundant invocations.

You would not typically override this method.

## See Also

[`document`](/documentation/AppKit/NSWindowController/document)

The document associated with the window controller.



---

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)