Who should call viewDidLoad on progammatically loaded views?

Posted by Remus Rusanu on Stack Overflow See other posts from Stack Overflow or by Remus Rusanu
Published on 2009-05-23T19:36:15Z Indexed on 2010/04/13 17:13 UTC
Read the original article Hit count: 313

Filed under:
|

When I need to load a view programatically I do the following:

MyController* myController = [[MyController alloc] init];
[[NSBundle mainBundle] loadNibNamed:@"myNib" owner:myController options:nil];
// use my controller here, eg. push it in the nav controller

This works fine, but my controller's viewDidLoad is never called. So I resorted to manually calling it after the loadNibNamed call, but it doesn't seem correct. I was expecting the framework to call the viewDidLoad on my behalf. Is this the right way or I'm missing something?

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about iphone-sdk