title: What is difference between UITableView methods and equivalent UITableViewDatasource methods?
body: <p>How is:</p>
  
  <p><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell</code></p>
  
  <p>different from:</p>
  
  <p><code>func cellForRow(at indexPath: IndexPath) -&gt; UITableViewCell?</code></p>
  
  <p>I recently ran into a bug where I was extending <code>UITableView</code> to be able to iterate through rows in a given section.</p>
  
  <pre><code>func forRows(inSection section: Int, condition: (UITableViewCell) -&gt; ()) {
  
      for row in 0..&lt;numberOfRows(inSection: section) {
          let cell = cellForRow(at: IndexPath(row: row, section: section))!
  
          condition(cell)
      }
  }
  </code></pre>
  
  <p>^^^ does not work, the cell is nil on the last row</p>
  
  <pre><code>func forRows(inSection section: Int, condition: (UITableViewCell) -&gt; ()) {
  
      for row in 0..&lt;dataSource!.tableView(self, numberOfRowsInSection: section) {
          let cell = dataSource!.tableView(self, cellForRowAt: IndexPath(row: row, section: section))
  
          condition(cell)
      }
  }
  </code></pre>
  
  <p>^^^ works. I get it, but I don't get it. </p>
  
  <p>What is different internally between tableView delegate methods and their equivalent methods on the tableView itself?</p>