If you are using a Storyboard, initWithCoder:
will be called. Reference document says:
If your app uses a storyboard to define a view controller and its
associated views, your app never initializes objects of that class
directly. Instead, view controllers are either instantiated by the
storyboard—either automatically by iOS when a segue is triggered or
programmatically when your app calls the storyboard object’s
instantiateViewControllerWithIdentifier: method. When instantiating a
view controller from a storyboard, iOS initializes the new view
controller by calling its initWithCoder: method instead. iOS
automatically sets the nibName property to a nib file stored inside
the storyboard.
The initWithCoder:
method isn't part of the default template of a .m file, so you have to add yourself in your UIViewController subclass:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Custom initialization
NSLog(@"Was called...");
}
return self;
}
There is no need to delete initWithNibName:bundle:
from your code, but it won't be called anyway.