views:

28

answers:

1

I have my main app view controller (File's Owner), its First Responder, View, and 3 other UIViewControllers in the same nib file. Every one of the 3 UIViewControllers is referenced on the main UIViewController as an IBOutlet.

My question is, when does the main UIViewController init those 3 UIViewControllers, in its life cycle (my guess is sometime before calling viewDidLoad) and should I worry with optimizing how and when they are loaded. The reasoning is obviously that if the app loads the main view controller and then right away starts loading the other view controllers, the user might have to wait for everything to get loaded first. But if I could still have the IBOutlets synthesized, but have the option to decide when those view controllers (and their views) are loaded, then this would definitely be an improvement.

ps. I have searched all over StackOverflow and the official documentation for an answer with no luck yet.

Thanks for any responses.

+1  A: 

The UIViewController doesn’t initialize the outlets, that’s done by the nib loading code before awakeFromNib and viewDidLoad. Anything that is in one nib file gets loaded, instantiated and intialized at the same time. So as long as your views are in the same nib there is no way to load them on demand. You should put the other views in different nib files and load them when they are needed. Putting everything in one nib is not a good idea.

Sven
Thanks for the answer. I've grouped views according to their functionality, and have been making use of different nib files dependent on which functionality they belong. I guess if that's the case I would have to break down my nibs in a view and a controller per nib.
haknick