title: All Classes Conforming to Protocol Inherit Default Implementation
body: <p>I've added a method to all my UIViewController subclasses that allows me to instantiate it from the class and the storyboard it's inside.</p>
  
  <p>All the methods follow this format:</p>
  
  <pre><code>class func instantiateFromStoryboard() -&gt; CameraViewController? {
  
      let storyboard = UIStoryboard(name: "Camera", bundle: nil)
  
      let initial = storyboard.instantiateInitialViewController()
  
      guard let controller = initial as? CameraViewController else {
          return nil
      }
  
      return controller
  }
  </code></pre>
  
  <p><em>Instead</em>, I would like to make a protocol, <code>Instantiatable</code>, that requires the above method along with a variable, <code>storyboardName: String</code>. </p>
  
  <p>Then, I'd like to extend this <code>Instantiatable</code> so it contains a similar implementation as above. My objective is that I can state that a <code>UIViewController</code> adheres to this protocol, and all that I have to define is the <code>storyboardName</code>.</p>
  
  <p>I feel like I'm close with this implementation:</p>
  
  <pre><code>protocol Instantiatable {
      var storyboardName: String { get }
      func instantiateFromStoryboard() -&gt; Self?
  }
  
  extension Instantiatable where Self: UIViewController {
      func instantiateFromStoryboard() -&gt; Self? {
  
          let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
  
          let initial = storyboard.instantiateInitialViewController()
  
          guard let controller = initial as? Self else {
              return nil
          }
  
          return controller
      }
  }
  </code></pre>
  
  <p>However, when I try to add conformance to <code>CameraViewController</code>, I get the error:</p>
  
  <blockquote>
    <p>Method <code>instantiateFromStoryboard()</code> in non-final class <code>CameraViewController</code> must return <code>Self</code> to conform to protocol <code>Instantiatable</code></p>
  </blockquote>
  
  <p>What am I missing?</p>
  
  <p>Thanks.</p>