When to use viewDidLoad and when to use awakeFromNib

ios, ios6, xcode

Solution

`awakeFromNib` is called when the associated nib file with a class is loaded . Any class that can own a nib can use it. `viewDidLoad` is used only by view controllers. It is usually called when loading from nib as well but it can also be called by a view created in memory (very rare circumstance.). If you are using controllers, then I would suggest you to use `viewDidLoad`

For more Refer this Answer

Problem

I've gotten pretty comfortable using the viewDidLoad method to execute things I want done at the beginning of a view, but reading one of Apple's tutorials they set the data controller for the class in the awakeFromNib method and did nothing in the awakeFromNib. I swapped it and it seemingly worked identically in my app, but I'm not sure if it was better to have it in awakeFromNib or viewDidLoad. When should I use either one?

Original source

Related problems