title: Swift: create programmatically UIViewController from xib
body: <p>I'm approaching to swift in this days and I've a question.</p>
  
  <p>What if I have to create programmatically a new UIViewController?</p>
  
  <p>Easy with an empty/new view controller:</p>
  
  <pre><code>var controller: UIViewController = UIViewController()
  controller.view.backgroundColor = UIColor.whiteColor()
  self.presentViewController(controller, animated: true, completion: nil)
  </code></pre>
  
  <p>Now, I have a xib file that I would like to load on the controller:</p>
  
  <pre><code>var controller: UIViewController = UIViewController(nibName: "FeedDetail", bundle: nil)
  controller.view.backgroundColor = UIColor.whiteColor()
  self.presentViewController(controller, animated: true, completion: nil)
  </code></pre>
  
  <p>This crash because:</p>
  
  <pre><code>'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "FeedDetail" nib but the view outlet was not set.'
  </code></pre>
  
  <p>I've already read this <a href="https://stackoverflow.com/questions/4763519/loaded-nib-but-the-view-outlet-was-not-set-new-to-interfacebuilder">post</a> and I can't understand what's wrong!</p>
  
  <p><img src="https://i.stack.imgur.com/Yvqhv.png" alt="enter image description here"></p>