tags:

views:

4725

answers:

3

I created a simple tab bar application in Xcode.

The default tab bar has 2 tab bar items. I add a third tab bar item and set its view controller attribute to a view i had created and subsequently saved called ThirdView.xib.

When I try to run, the first two default tabs work fine. The third one I added throws this error:

    *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ThirdView" nib but 
the view outlet was not set.'

I apologize as I'm a huge iPhone-SDK n00b, but no manner of clicking and dragging and control-click dragging is allowing me to set the view outlet on the third view I had created.

+1  A: 

Check the filename you're passing to initFromNib (or however you're loading the controller). A typo or including the extension can result in this message.

Andrew Grant
+2  A: 

I had similar problem 10 mins ago, it was unsaved xib file :). For some reasons XCode doesn't ask to save xib files when one hit run.

But if that isn't the case, I would double check if the view is indeed connected in the xib file.

To do so open ThirdView.xib as plain text file (right click > open as > plain text file) and search for text: ">view<". If the view is connected you should find something similar to the code below:

<object class="IBConnectionRecord">
 <object class="IBCocoaTouchOutletConnection" key="connection">
  <string key="label">view</string>
  <reference key="source" ref="372490531"/>
  <reference key="destination" ref="191373211"/>
 </object>
 <int key="connectionID">15</int>
</object>

If you can't find it this could mean that the problem is caused by a bug in Interface Builder. Then you can try to add the connection by hand. Let me know if that is the case.

Piotr Czapla
A: 

Wow! Thank you for this answer Piotr! I just found this post when googling the same answer and indeed you were right, I had created the xib file but not clicked "save". It was driving me crazy because I was sure everything seemed right. As soon as I saved the xib and rebuilt, I stopped having that error.

That was a HUGE help. Thanks! Hope other people also find this post!