---
title: "init(window:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nswindowcontroller/init(window:)"
---

# init(window:)

Returns a window controller initialized with a given window.

## Declaration

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

## Parameters

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

## Return Value

Return Value A newly initialized window controller.

## Discussion

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 property to 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 willCloseNotifications 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 NSWindow’s windowShouldClose: delegate method.

## See Also

### Related Documentation

- [Document-Based App Programming Guide for Mac](apple-archive/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/Introduction.md)

### Initializing Window Controllers

- [init(windowNibName:)](appkit/nswindowcontroller/init(windownibname:).md)
- [init(windowNibName:owner:)](appkit/nswindowcontroller/init(windownibname:owner:).md)
- [init(windowNibPath:owner:)](appkit/nswindowcontroller/init(windownibpath:owner:).md)
