title: Protocol inheritance + delegates in Swift
body: <p>I have a class with a delegate. I create a subclass, which also has a delegate. I wanted to let the protocol used for the second delegate extend the protocol used for first delegate:</p>
  
  <pre><code>protocol MySuperClassProtocol {
      func foo()
  }
  
  class MySuperClass {
      var delegate:MySuperClassProtocol?
  }
  
  protocol MySubClassProtocol:MySuperClassProtocol {
      func bar()
  }
  
  class MySubClass: MySuperClass {
      override var delegate:MySubClassProtocol? // compiler error - "cannot override..."
  
      func test() {
          delegate?.foo()
          delegate?.bar()
      }
  }
  
  class UserClass:MySubClassProtocol {
      func foo() {
          println("foo!")
      }
      func bar() {
          println("bar")
      }
  } 
  </code></pre>
  
  <p>Is there a way to solve this? The only possible solution I see is to make the 2 protocols independent of each other, and use different names. Like this:</p>
  
  <pre><code>protocol MySuperClassProtocol {
      func foo()
  }
  
  class MySuperClass {
      var mySuperClassDelegate:MySuperClassProtocol?
  }
  
  protocol MySubClassProtocol {
      func bar()
  }
  
  class MySubClass: MySuperClass {
      var mySubClassDelegate:MySubClassProtocol?
  
      func test() {
          mySuperClassDelegate?.foo()
          mySubClassDelegate?.bar()
      }
  }
  
  class UserClass:MySuperClassProtocol, MySubClassProtocol {
      func foo() {
          println("foo!")
      }
      func bar() {
          println("bar")
      }
  }
  </code></pre>
  
  <p>But this looks a bit weird + will not let me use naming convention for delegate- "delegate".</p>