title: How can I access the child's makeIterator function?
body: <p>I have a parent class <code>BaseModels</code> which implement the protocol <code>Sequence</code>:</p>
  
  <pre><code>class BaseModel { 
      var dict : Dictionary
      init (json: AnyObject?) { dict = json as? Dictionary }
  }
  class BaseModels : Sequence {
      var arr : Array&lt;Dictionary&gt;
  
      init (json: AnyObject?) { arr = json as? Array&lt;Dictionary&gt; }
      func makeIterator() -&gt; AnyIterator&lt;BaseModel&gt; {
          var nextIndex = 0;
  
          return AnyIterator {
              guard let arr = self.arr, nextIndex &lt; arr.count else { return nil }
              let curIndex = nextIndex; nextIndex += 1;
              return BaseModel(json: arr[curIndex] as AnyObject?)
          }
      }
  }
  </code></pre>
  
  <p>And I have child class who inherited from this parent:</p>
  
  <pre><code>class Child : BaseModel { ... }
  class Childs : BaseModels {
      func makeIterator() -&gt; AnyIterator&lt;Child&gt; {
          var nextIndex = 0;
  
          return AnyIterator {
              guard let arr = self.arr, nextIndex &lt; arr.count else { return nil }
              let curIndex = nextIndex; nextIndex += 1;
              return Child(json: arr[curIndex] as AnyObject?)
          }
      }
  }
  </code></pre>
  
  <p>But when I do this:</p>
  
  <pre><code>let childs = Childs(json: someJsonArray);
  for (idx, el) in childs.enumerate() {
      // when I check the el's data type in here, its type is actually BaseModel, not Child. 
  }
  </code></pre>
  
  <p>Why the <code>el</code> type is BaseModel, not Child? How can I implement this correctly so that when I call <code>enumerate</code> or <code>for ... in ...</code>, it returns Child type class not BaseModel class?</p>
  
  <p>PS: when I add <code>override</code> in front of <code>func makeIterator() -&gt; AnyIterator&lt;Child&gt;</code>, Xcode says "Method does not override any method from its superclass".</p>