Invoking initWithNibName:bundle: indirectly through init


Could someone please elaborate on a particular initialization behavior for me. In Chapter 13, More Modal Controllers, the tableView:didSelectRowAtIndexPath: method of ItemsViewController is called, which creates an instance of DetailViewController by sending it the message init.

The author states that calling init will “eventually” call initWithNibName:bundle:. Unless I’m missing some code, we never override NSObject’s init method. Also, UIViewController does not implement init. So the way I understand it, calling init should call the ultimate superclass, NSObject, and just return a pointer. How does UIViewController’s instance method, initWithNibName:bundle:, “indirectly” get invoked? I haven’t been able to get an answer to this question from researching various online documentation.


Most classes implement a reasonable default behaviour for their init method calling a designated initializer, even though one might think otherwise.

For example, UIViewController might do something like this:

@implementation UIViewController

- (id)init
   return [self initWithNibName:nil bundle:nil];

- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
   return ...


Thanks. This forum is immensely helpful in getting up to speed.