Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View outlet not available to File's Owner

I was getting the following message upon creating a new view controller. Everything was compiling a-okay in Xcode without errors, but the app was immediately quitting upon loading the new view from a RootViewController.

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

To resolve this, I tried connecting the File's Owner to the view, but the view outlet wasn't even available to the File's owner.

like image 405
Old McStopher Avatar asked Mar 08 '11 01:03

Old McStopher


1 Answers

Moved from question section, per @Tim Post's suggestion.

Discovery:

I finally realized that when I added this View XIB, the File's Owner had been set to NSObject instead of HomeViewController (my newly-created view controller). Once I set the class identity in the indentity inspector, the view outlet was then ready to be connected to the view.

The app now loads and the new view loads perfectly. Just sharing for the benefit of the SO community.

Conclusion:

When creating a new View XIB, make sure to set the class identity to the desired view controller in the indentity inspector (Cmd+4). It may be set to NSObject by default.

The view outlet should then be available.

like image 108
Old McStopher Avatar answered Sep 21 '22 01:09

Old McStopher