<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindowController/init(window:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindowController(im)initWithWindow:"
  },
  "title" : "init(window:)"
}
-->

# init(window:)

Returns a window controller initialized with a given window.

```
init(window: NSWindow?)
```

## Parameters

`window`

The window object to manage; can be `nil`.

## Return Value

A newly initialized window controller.

## Discussion

This method is the designated initializer for `NSWindowController`.

This initializer is useful when a window has been loaded but no window controller is assigned. The default initialization turns on cascading, sets the [`shouldCloseDocument`](/documentation/AppKit/NSWindowController/shouldCloseDocument) property to <doc://com.apple.documentation/documentation/Swift/false>, and sets the window frame autosave name to an empty string. As a side effect, the created window controller is added as an observer of the [`willCloseNotification`](/documentation/AppKit/NSWindow/willCloseNotification) posted by that window object (which is handled by a private method). If you make the window controller a delegate of the window, you can implement the [`NSWindow`](/documentation/AppKit/NSWindow) delegate method `windowShouldClose(_:)`.

---

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)