This question already has an answer here:
What is the general guideline for the difference between the types of code (object allocation, setting up ui elements, network calls, etc.) that should go in the init method vs. a viewDidLoad type method for a view controller?
Init => call at/use for initialize your ViewController and Initialize only for
UIViewController
and not it's viewsViewDidLoad => call at/use for load view , This method gest called after the nib is loaded
Initializing variables in an iOS application is something you will face every project. Choosing the right place to init your variables can sometimes be tricky. I recently faced a problem that was difficult to reproduce and changed some variables who were initialized in my viewDidLoad method and for who I couldn’t understand that they were changing.
Possible methods to init variables in your viewcontroller are: - init - viewDidLoad - viewWillAppear - viewDidAppear
To explain my point I started a new project with the template Tab Bar Application. I added logging statements to the viewDidLoad methods in both view controllers. A also added a button to the second view controller who would initialize some images that would give me a memory warning.
After logging some statements and came to the following conclusion:
=> Now changing to the first tab
If you initialize variables in the viewDidLoad method then please keep in mind that these variables could be reinitialized after receiving a memory warning. Cocoa will remove the view and your viewDidLoad method will be triggered again once you go to that specific view controller.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926