I often see this line of code
awakeFromNib method in the implementation of a view controller
My understanding is it is telling the super class of this view controller (which would be the window) to
awakeFromNib. Am I right? If so, why do we have to tell the window to awake in the
awakeFromNib method of a UIView Controller sub-class?
My understanding is it is telling the super class of this view controller ...
right so far...
(which would be the window)
oops - that's the source of your confusion.
The "super class of the view controller" is
UIViewController. "super" is referring to the base class that your UIViewController sub-class inherits from; it doesn't have anything to do with the window that encloses your view.
So, what this is doing is invoking the default
awakeFromNib implementation of a basic
UIViewController, in addition to whatever you're doing in your sub-class implementation.
What David said above is correct,
Now for your question "why do we have to tell the window to awake in the awakeFromNib method of a UIView Controller sub-class?"
if there is any custom modification or any data that you want to load before your ViewController loads we should use the
awakeFromNib is called when the controller itself is unarchived from a nib.