title: Loading a nib file inside a UIViewController
body: <p>I'm experimenting on how to load nib files to a <code>UIViewController</code>. </p>
  
  <p>I have created a separate nib file called <strong>Email</strong>. First I noticed that when the view controller is loaded, the <code>initWithNibName</code> method isn't getting called. So I called it from the <code>viewDidLoad</code> method manually like this,</p>
  
  <pre><code>[self initWithNibName:@"Email" bundle:[NSBundle mainBundle]];
  </code></pre>
  
  <p>It did not work. Also I got a warning saying <em>Expression result unused</em>.</p>
  
  <p>And I searched on the internet and came across <a href="http://www.indelible.org/ink/nib-loading/">this</a> article and implemented the <code>loadView</code> method as described like so,</p>
  
  <pre><code>- (void)loadView
  {
      [super loadView];
  
      UINib *nib = [UINib nibWithNibName:@"Email" bundle:nil];
      [nib instantiateWithOwner:self options:nil];
  }
  </code></pre>
  
  <p>The method gets called but still the view controller is empty!</p>
  
  <p>Can anybody tell me what I'm overlooking here and how this can be done?</p>
  
  <p>Thank you.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>First off, thanks for all the responses. However <strong>voromax</strong> and <strong>svena</strong>'s answers suggest that I should remove segues and load nibs automatically which I'm not very fond of. Anil's answer works find and now I have one last hurdle to jump.</p>
  
  <p>I have multiple nib files. Depending on the user's selection, it should load a specific nib. So what I tried was, put all the nibs inside the array like so,</p>
  
  <pre><code>- (void)loadView
  {
      [super loadView];
  
      NSArray *nibs = [[NSArray alloc] initWithObjects:
                       [[NSBundle mainBundle] loadNibNamed:@"Facsimile" owner:self options:nil],
                       [[NSBundle mainBundle] loadNibNamed:@"Email" owner:self options:nil],
                       [[NSBundle mainBundle] loadNibNamed:@"Memorandum" owner:self options:nil],
                       [[NSBundle mainBundle] loadNibNamed:@"ProjectMemo" owner:self options:nil], nil];
  
  
      self.view = [nibs objectAtIndex:0];
  }
  </code></pre>
  
  <p>and access it using its index like this <code>self.view = [nibs objectAtIndex:1];</code>. But it throws an error *Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM _setViewDelegate:]: unrecognized selector sent to instance 0xd56fd20'*</p>
  
  <p>Why is this error coming up? If its not possible, I'm open to suggestions.</p>
  
  <p>Thanks again. And sorry for kinda dragging this out a bit.</p>