---
title: "setWindow(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocument/setwindow(_:)"
---

# setWindow(_:)

Sets the window outlet of this document to the specified value.

## Declaration

```swift
func setWindow(_ window: NSWindow?)
```

## Parameters

- `window`: The window to which the receiver’s window outlet points.

## Discussion

Discussion This method is invoked automatically during the loading of any nib for which this document is the file’s owner, if the file’s owner window outlet is connected in the nib. You should not invoke this method directly, and typically you would not override it either.

## See Also

### Managing Document Windows

- [showWindows()](appkit/nsdocument/showwindows().md)
- [windowForSheet](appkit/nsdocument/windowforsheet.md)
- [displayName](appkit/nsdocument/displayname.md)
- [defaultDraftName()](appkit/nsdocument/defaultdraftname().md)
- [encodeRestorableState(with:backgroundQueue:)](appkit/nsdocument/encoderestorablestate(with:backgroundqueue:).md)
