I've been trying to verify in my tests (GTM) that when a nib file is loaded, its IBOutlets were properly connected in InterfaceBuilder.
However I keep getting nil references, despite calling [myViewController viewDidLoad] before asserting that the reference should exist.
Are there any gotchas here, or should this be mocked somehow ?
cheers
calling [myViewContoller viewDidLoad]
does not load the view. You want [myViewController loadView]
, which loads up the .nib and the references.
You shouldn't be calling -viewDidLoad.
If by "when a nib file is loaded", you mean you're calling -initWithNibName:bundle:, that does not load the nib. That just sets the nib name that is used to load the view. The "correct" way to load the view is to call -[UIViewController view] (which calls loadView if it was not already loaded, which by default loads from the nib, which has a default name of [[self class] description] or so, I think). -[UIViewController view] will call viewDidLoad for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With