Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode "-[UIViewController _loadViewFromNibNamed:bundle:] loaded the nib but the view outlet was not set." error

I'm using Xcode 4 and when I run my app, the first screen doesn't load. It fails in the simulators and on a device. I've searched for answers and they all say to make sure I've dragged the circles in Files Owner to the correct views. Sorry I don't remember the names of the things, I'm new to Xcode. I've dragged the circles to the correct view and tried many things but none of them worked. What could I be doing wrong?

Here is the full error:

2012-02-19 12:59:54.655 Ponyboard[271:207]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PonyboardViewController" nib but the view outlet was not set.' 

*** Call stack at first throw:  
(  
    0   CoreFoundation                      0x00f095a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0105d313 objc_exception_throw + 44
    2   CoreFoundation                      0x00ec1ef8 +[NSException raise:format:arguments:] + 136
    3   CoreFoundation                      0x00ec1e6a +[NSException raise:format:] + 58
    4   UIKit                               0x0020d709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
    5   UIKit                               0x0020b134 -[UIViewController loadView] + 120
    6   UIKit                               0x0020b00e -[UIViewController view] + 56
    7   UIKit                               0x0017ed42 -[UIWindow addRootViewControllerViewIfPossible] + 51
    8   Ponyboard                           0x00002a87 -[PonyboardAppDelegate application:didFinishLaunchingWithOptions:] + 135
    9   UIKit                               0x0015bc89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    10  UIKit                               0x0015dd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    11  UIKit                               0x00168617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                               0x00160abf -[UIApplication sendEvent:] + 71
    13  UIKit                               0x00165f2e _UIApplicationHandleEvent + 7576
    14  GraphicsServices                    0x031fd992 PurpleEventCallback + 1550
    15  CoreFoundation                      0x00eea944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16  CoreFoundation                      0x00e4acf7 __CFRunLoopDoSource1 + 215
    17  CoreFoundation                      0x00e47f83 __CFRunLoopRun + 979
    18  CoreFoundation                      0x00e47840 CFRunLoopRunSpecific + 208
    19  CoreFoundation                      0x00e47761 CFRunLoopRunInMode + 97
    20  UIKit                               0x0015d7d2 -[UIApplication _run] + 623
    21  UIKit                               0x00169c93 UIApplicationMain + 1160
    22  Ponyboard                           0x000029c9 main + 121
    23  Ponyboard                           0x00002945 start + 53
)
terminate called after throwing an instance of 'NSException'
like image 247
austin Avatar asked Feb 20 '12 01:02

austin


3 Answers

Are you sure you have a UIView (or subclass) assigned to the "view" property of PonyboardViewController? Right click on "File Owner" in the left pane of the xib for PonyboardViewController and verify that the "view" outlet is set.

If not, set it to a view!

like image 119
Nick Avatar answered Oct 20 '22 16:10

Nick


I just have the same problem as you, so I fixed it like that: this is my code block:

self.chatsView = [[ChatsView alloc] initWithNibName:@"ChatsView" bundle:nil];

I click ChatsView.xib to find the "File's owner", then hover my mouse over the "File's owner", and right click, that will prompt something like this:

The unconnected 'view' outlet

you must drag the "view" Outlet to connect to the View which have two subViews: Search Bar&Table View in my xib file.

The connected 'view' outlet

like image 32
Levine Veblen Avatar answered Oct 20 '22 18:10

Levine Veblen


Your problem probably lies with the XIB or Stroyborad scene. Check whether the View is connected properly to the class.

I've tried, and it works fine for me after doing it.

like image 2
Alvin George Avatar answered Oct 20 '22 17:10

Alvin George