title: Swift protocol method usage
body: <p>So I've started learning Swift, because it looks way better than ObjC. However I must be tired (its 2:37 AM here right now) because I cant see issue why Xcode screams I am trying to call undefined member. See the code below:</p>
  
  <p>PeopleStackViewDataSource.swift</p>
  
  <pre><code>import Foundation
  import UIKit
  
  protocol PeopleStackViewDataSource {
  
      func stackViewNumberOfItems(stackView: PeopleStackView) -&gt; Int
      func stackViewGetView(indexPath: NSIndexPath) -&gt; UIView
  }
  </code></pre>
  
  <p>PeopleStackView.swift</p>
  
  <pre><code>import Foundation
  import UIKit
  
  class PeopleStackView: UIView {
  
      var datasource: PeopleStackViewDataSource? {
      didSet {
          self.redraw()
      }
      }
  
      var scaleDownBy: Double = 0.1
  
      init(frame: CGRect) {
          super.init(frame: frame)
  
      }
  
      init(frame: CGRect, datasource: PeopleStackViewDataSource) {
          super.init(frame: frame);
          self.datasource = datasource;
      }
  
      func numberOfItems() -&gt; Int {
          return self.datasource ? self.datasource.stackViewNumberOfItems(self) : 0
      }
  
      func redraw() {
  
      }
  
  
  }
  </code></pre>
  
  <p>The issue is this line <code>return self.datasource ? self.datasource.stackViewNumberOfItems(self) : 0</code> where Xcode says that <code>stackViewNumberOfItems(self)</code> </p>
  
  <blockquote>
    <p>PeopleStackViewDataSource?' does not have a member named
    'stackViewNumberOfItems</p>
  </blockquote>
  
  <p>So, where is the issue?</p>