I am loading a UIViewController
from a bundle with initWithNibName:bundle:
. If I set a breakpoint in its viewDidLoad
I can see that its view
is set. I can also see this when viewing About.xib
in the Interface Builder.
However once the view is actually used for the first time (in a call to [self.navigationController pushViewController:viewController animated:YES]
according to my app's logic) I get this error:
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "About" nib but the view outlet was not set.'
This is the call that also triggers viewDidLoad
. So apparently during the call, view
is first non-nil (as it should be) and later apparently becomes nil again.
If I alternatively type po [viewController view]
in the debugger immediately prior to the call I get this error (which is presumably just another presentation of the same symptom):
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3).. The process has been returned to the state before expression evaluation.
How can I load and use the view controller in conjunction with an existing navigation bar without running into these errors?
UPDATE The problem apparently disappears if I load the view controller from my a storyboard (not necessarily my main storyboard) instead of from a XIB file.