Chapter9: Application Crashes on loadView


#1

Hi,

I’ve been having problems when setting itemsViewController as the RootViewController of the Homepwner project. The message I get is this:

2013-02-21 13:14:54.421 Homepwner[2052:11303] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the “ItemsViewController” nib but the view outlet was not set.’

I’m puzzled because even the solution codes provided at this website throw the same exception.

Regards,


#2

When you say the solution code throws the same exception, have you compiled the solution code as a whole or have you just copied and pasted some of it? The error suggests that there may be a problem with the way you are calling initWithNibName:bundle: so if you can paste the lines from your code that contain this message that will help me figure out what your problem may be.


#3

[quote]*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _loadViewFromNibNamed:bundle:] loaded the “ItemsViewController” nib but the view outlet was [color=#FF0000]not set[/color].

I’m puzzled because even the solution codes provided at this website throw the same exception.
[/quote]
Make sure that ItemsViewController’s view outlet is connected to a view in the nib file.


#4

Hi,

First of all, thanks for your suggestions. I have really appreciated it.
I have been working the chapters in the book in my MacBook Pro and I get this exception, It however works fine in my IMAC. I didn’t copy and paste ( at first :slight_smile: ) but compiled the solution’s project as a whole. I followed then the suggestion by ibex, created a ItemsViewController.xib added a UIView and UITableView. Then defined ItemsViewController as File’s Owner and the delegate to the UITableView and finally set the ItemsViewController’s view outlet to the view within the xib file.

I wonder why it had to be done in that way and not as the book suggested but the final result was the same.

Thanks,