viewDidLoad(), LoadView()

iOS picture iOS · Mar 2, 2011 · Viewed 29k times · Source

What is the difference between viewDidLoad() and LoadView()? In what way are they different from each other?

Which one is better when we develop applications without using XIB ?

Thanks .

Answer

Ishu picture Ishu · Mar 2, 2011

ViewDidLoad is called when your view loading is finished and loadView is called when loading starts.

And when you make a new project you see comments on these methods which clearly gives a tip when you should use which function

see this

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

These comments are clear and easy to understand.