In my case I was loading a view controller like so:
YellowViewController *yellowController = [[YellowViewController alloc] initWithNibName:@"YellowViev" bundle:nil];
whilst my bundle contained an YellowView.xib. I was using an "v" instead "w" in my NIB name.
So, yeah, check the names. XCode is pretty forgiving (and misleading) here. It would instantiate an object (from an non-existent NIB), in my case a view controller with a view member set to nil. Perhaps a better approach would be to return nil instead a half-baked, incorrect object. Instead it set me to a wild goose chase, to check the view outlet in the NIB and the ensuing scratching of the head.
The error message before the crash wasn't too helpful either:
ViewSwitcher[30112:20b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController loadView] loaded the "YellowViev" nib but no view was set.'
No comments:
Post a Comment