“Fun” with initWithNibName: “Loaded the NewEntrycontroller nib but no view was set”

Don’t get me wrong, I love Cocoa development. Not so long ago I fell in love with Objective-C in spite of its ugly syntax (damn it’s powerful), and a couple of weeks ago I stumbled across Aaron Hillegass’s Cocoa Programming for Mac OS X which is a great book about “Idiomatic Cocoa Programming”.

Anyways, there are error messages in Cocoa that  are straight lies, like the one in the title. I initialized my controller like this:


newEntryController = [[NewEntryController alloc] initWithNibName:@"NewEntryController.xib" bundle:nil];

All went fine until my NavigationController wanted to show it. Then I got the error message, of course only in the debug console. The app itself simply didn’t show the view I would have expected.

After some digging through the documentation (especially the team play of  initWithNibName, loadView and viewDidLoad) I still had no clue. I looked at some sample application and then it hit me: The nib name should be just NewEntryController without the extension!

I would really appreciate a good error message when a nib file can’t be found …

Tags: , , , , , , , ,

Leave a Reply


uberdose 2.0

L-l-look at you, hacker.