title: Call setup code of superclass
body: <p>My class A is initialised like that:</p>
  
  <pre><code>- (instancetype)init // designated initializer
  {
      self = [super init];
  
      if (self) {
          [self setup]; // just sets some properties
      }
  
      return self;
  }
  </code></pre>
  
  <p>I have the following class B which subclasses A:</p>
  
  <pre><code>- (instancetype)init 
  {
      self = [super init]; // calls the initializer of A and SHOULD call the setup code of A but it does not
  
      if (self) {
          [self setup]; // just sets some properties for B
      }
  
      return self;
  }
  </code></pre>
  
  <h1><strong>My Problem:</strong></h1>
  
  <p>B should call A's setup method but it does not due to the dynamic typing of Objective-C. Instead B calls its setup code <strong>twice</strong>.</p>
  
  <p>How can I resolve this problem (besides renaming the methods) or even better <strong>ARE THERE ANY BETTER APPROACHES?</strong></p>
  
  <hr>
  
  <p><em>I could move the code written in <code>setup</code> to <code>init</code> but the problem is that I have more than one designated initializer (for example: UIViewControllers has <code>initWithFrame:</code> and <code>initWithCoder:</code>) and I am lazy about writing code twice.</em></p>