title: Custom init method in Objective-C, how to avoid recursion?
body: <p>I want to create a subclass of UINavigationController which always starts with the same root controller. Nothing special, so (to me) it makes perfect sense to override the init method like this:</p>
  
  <pre><code>- (id) init {
     rootController = [[MyController alloc] init];
  
     if (self = [super initWithRootViewController:rootController]) {
         // do some more initialization
     }
  
     return self;
  }
  </code></pre>
  
  <p>This obviously creates a problem, because [super initWithRootViewController] will call [UINavigationController init], which is of course our overridden init method, so infinite recursion will occur.</p>
  
  <p>I don't want to create an init method with a different name like "initCustom".</p>
  
  <p>There's currently only one solution I can come up with, but I really hate this kind of hack:</p>
  
  <pre><code>- (id) init {
     if (initCalled)
         return self;
  
     initCalled = YES;
  
     rootController = [[MyController alloc] init];
  
     if (self = [super initWithRootViewController:rootController]) {
         // do some more initialization
     }
  
     return self;
  }
  </code></pre>
  
  <p>So my question is: <strong>is there a better way of handling this? I'm sure I'm missing something very obvious, but I don't see it.</strong></p>
  
  <p><strong>EDIT</strong>: The reason why I want to do this, as can be seen in one of my comments below:</p>
  
  <p>I want to create a navigation controller that always starts with a specific view controller. I want to hide this from the consumer of the class. No need to expose things that don't need exposing. Makes life a lot easier, and code a lot cleaner (one of the reasons encapsulation was invented, right?)</p>