The default init method signature on XCode-generated view controllers is:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ }
I’ve seen these initialized with both values supplied, just the nib name (with bundle as nil), or just nil as both. All seem to work.
How does the UIViewController really handle self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];? Is there a disadvantage to just passing in nil for both values?
If you pass
nilas the nibName, the method will look for a nib with the same filename as your view controller.For instance, if you have a view controller called
MyViewControllerit will look for aMyViewController.xibnib file.If no nib is found, you will need to override the
loadViewmethod to create and assign a UIView to the controller’s view outlet.