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

# contentViewController

The main content view controller for the window.

```
var contentViewController: NSViewController? { get set }
```

## Discussion

The value of this property provides the content view of the window. Setting this value removes the existing value of [`contentView`](/documentation/AppKit/NSWindow/contentView) and makes the `contentViewController.view` the main content view for the window. By default, the value of this property is `nil`.

The content view controller controls only the [`contentView`](/documentation/AppKit/NSWindow/contentView) object, and not the title of the window. The window title can easily be bound to the [`contentViewController`](/documentation/AppKit/NSWindow/contentViewController) object using code such as: `[window bind:NSTitleBinding toObject:contentViewController withKeyPath:@"title" options:nil]`. Setting [`contentViewController`](/documentation/AppKit/NSWindow/contentViewController) causes the window to resize based on the current size of the [`contentViewController`](/documentation/AppKit/NSWindow/contentViewController); to restrict the size of the window, use Auto Layout (note that the value of this property is encoded in the NIB). Directly assigning a [`contentView`](/documentation/AppKit/NSWindow/contentView) value clears out the root view controller.

## See Also

[`+  windowWithContentViewController:`](/documentation/AppKit/NSWindow/init(contentViewController:))

Creates a titled window that contains the specified content view 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)