title: Swift: Custom ViewController initializers
body: <p>How do you add custom initializers to <code>UIViewController</code> subclasses in Swift?</p>
  
  <p>I've created a sub class of <code>UIViewController</code> that looks something like this:</p>
  
  <pre><code>class MyViewController : UIViewController
  {
      init(leftVC:UIViewController, rightVC:UIViewController, gap:Int)
      {
          self.leftVC = leftVC;
          self.rightVC = rightVC;
          self.gap = gap;
  
          super.init();
  
          setupScrollView();
          setupViewControllers();
      }
  }
  </code></pre>
  
  <p>When I run it I get a fatal error:</p>
  
  <blockquote>
    <p>fatal error: use of unimplemented initializer 'init(nibName:bundle:)' for class 'MyApp.MyViewController'</p>
  </blockquote>
  
  <p>I've read elewhere that when adding a custom initializer one has to also override <code>init(coder aDecoder:NSCoder)</code> so let's override that <code>init</code> and see what happens:</p>
  
  <pre><code>override init(coder aDecoder: NSCoder)
  {
      super.init(coder: aDecoder);
  }
  </code></pre>
  
  <p>If I add this, Xcode complains that <code>self.leftVC is not initialized at super.init call</code>. So I guess that can't be the solution either. So I wonder how can I add custom initializers properly to a <code>ViewController</code> subclass in Swift (since in Objective-C this seems not to be a problem)?</p>