The lifecycle starts with alloc and initialization of course
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)aBundle;
Can I build a UIViewController ’s view in code (i.e. w/o a .xib)?
Yes.
If no .xib is found using mechanism above, UIViewController will call - (void)loadView on itself.
loadView ’s implementation MUST set the view property in the UIViewController .
Don’t implement loadView AND specify a .xib file (it’s undefined what this would mean). Stanford
This is UIViewController ’s d e s i g n at e d i n it i a l i z e r.
The UIViewController tries to get its view from the specified .xib file called nibName.
If nibName is nil , it uses the name of the class as the nibName ( HappinessViewController.xib).
The bundle allows you to specify one of a number of different .xib files (localization).
We’ll cover NSBundle later in the course when we talk about localization.
Passing nil for aBundle basically means “look in the Resources folder from Xcode.”
Initializing UIViewController with init is very common, it means nibName is nil & aBundle is ni