<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/init(contentViewController:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(cm)windowWithContentViewController:"
  },
  "title" : "init(contentViewController:)"
}
-->

# init(contentViewController:)

Creates a titled window that contains the specified content view controller.

```
convenience init(contentViewController: NSViewController)
```

## Parameters

`contentViewController`

The view controller that provides the main content view for the window. The window’s [`contentView`](/documentation/AppKit/NSWindow/contentView) property is set to `contentViewController``.view`.

## Return Value

A window with the content view controller set to the passed-in view controller object.

## Discussion

This method creates a basic window object that is titled, closable, resizable, and miniaturizable. By default, the window’s title is automatically bound to the title of `contentViewController`. You can control the size of the window by using Auto Layout and applying size constraints to the view or its subviews. The initial size of the window is set to the initial size of [`contentView`](/documentation/AppKit/NSWindow/contentView) (that is, the size of `contentViewController``.view`). The newly created window has [`isReleasedWhenClosed`](/documentation/AppKit/NSWindow/isReleasedWhenClosed) set to <doc://com.apple.documentation/documentation/Swift/false>, and it must be explicitly retained to keep the window instance alive.

## See Also

  [Window Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/WinPanel/Introduction.html#//apple_ref/doc/uid/10000031i)

[`contentViewController`](/documentation/AppKit/NSWindow/contentViewController)

The main content view controller for the window.



---

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)