<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/init(nibName:bundle:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)initWithNibName:bundle:"
  },
  "title" : "init(nibName:bundle:)"
}
-->

# init(nibName:bundle:)

Creates a view controller with the nib file in the specified bundle.

```
init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)
```

## Parameters

`nibNameOrNil`

The name of the nib file to associate with the view controller. The nib file name should not contain any leading path information. If you specify `nil`, the [`nibName`](/documentation/UIKit/UIViewController/nibName) property is set to `nil`.

`nibBundleOrNil`

The bundle in which to search for the nib file. This method looks for the nib file in the bundle’s language-specific project directories first, followed by the Resources directory.

## Return Value

A newly initialized [`UIViewController`](/documentation/UIKit/UIViewController) object.

## Discussion

This is the designated initializer for this class. When using a storyboard to define your view controller and its associated views, you never initialize your view controller class directly. Instead, view controllers are instantiated by the storyboard either automatically when a segue is triggered or programmatically when your app calls the [`instantiateViewController(withIdentifier:)`](/documentation/UIKit/UIStoryboard/instantiateViewController(withIdentifier:)) method of a storyboard object. When instantiating a view controller from a storyboard, iOS initializes the new view controller by calling its [`init(coder:)`](/documentation/UIKit/UIViewController/init(coder:)) method instead of this method and sets the [`nibName`](/documentation/UIKit/UIViewController/nibName) property to a nib file stored inside the storyboard.

The nib file you specify is not loaded right away. It is loaded the first time the view controller’s view is accessed. If you want to perform additional initialization after the nib file is loaded, override the [`viewDidLoad()`](/documentation/UIKit/UIViewController/viewDidLoad()) method and perform your tasks there.

If you specify `nil` for the `nibName` parameter and you do not override the [`loadView()`](/documentation/UIKit/UIViewController/loadView()) method, the view controller searches for a nib file as described in the [`nibName`](/documentation/UIKit/UIViewController/nibName) property.

For more information about how a view controller loads its view, see [View Controller Programming Guide for iOS](https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/index.html#//apple_ref/doc/uid/TP40007457).

## See Also

[`loadView()`](/documentation/UIKit/UIViewController/loadView())

Creates the view that the controller manages.

[`nibBundle`](/documentation/UIKit/UIViewController/nibBundle)

The view controller’s nib bundle if it exists.

[`nibName`](/documentation/UIKit/UIViewController/nibName)

The name of the view controller’s nib file, if one was specified.

[`storyboard`](/documentation/UIKit/UIViewController/storyboard)

The storyboard from which the view controller originated.



---

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)