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

# init(nibName:bundle:)

Returns a view controller object initialized to the nib file in the specified bundle.

```
init(nibName nibNameOrNil: NSNib.Name?, bundle nibBundleOrNil: Bundle?)
```

## Parameters

`nibNameOrNil`

The name of the nib file, without any leading path information.

`nibBundleOrNil`

The bundle in which to search for the nib file. If you specify `nil`, this method looks for the nib file in the main bundle.

## Return Value

The initialized [`NSViewController`](/documentation/AppKit/NSViewController) object.

## Discussion

The [`NSViewController`](/documentation/AppKit/NSViewController) object looks for the nib file in the bundle’s language-specific project directories first, followed by the Resources directory.

The specified nib file should typically have the class of the file’s owner set to [`NSViewController`](/documentation/AppKit/NSViewController), or a custom subclass, with the `view` outlet connected to a view.

If you pass in `nil` for `nibNameOrNil`, [`nibName`](/documentation/AppKit/NSViewController/nibName) returns `nil` and [`loadView()`](/documentation/AppKit/NSViewController/loadView()) throws an exception; in this case you must set [`view`](/documentation/AppKit/NSViewController/view) before [`view`](/documentation/AppKit/NSViewController/view) is invoked, or override [`loadView()`](/documentation/AppKit/NSViewController/loadView()).

---

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)