views:

17

answers:

2

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

A: 

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.

tc.
A: 

calling [myViewContoller viewDidLoad] does not load the view. You want [myViewController loadView], which loads up the .nib and the references.

kuroutadori
Thanks to both of you, accepted this answer for the sake of brievity.
julien