title: tableView.cellForRowAtIndexPath(indexPath) return nil
body: <p>I got a validation function that loop through my table view, the problem is that it return nil cell at some point.</p>
  
  <pre><code>for var section = 0; section &lt; self.tableView.numberOfSections(); ++section {
      for var row = 0; row &lt; self.tableView.numberOfRowsInSection(section); ++row {
          var indexPath = NSIndexPath(forRow: row, inSection: section)
          if section &gt; 0 {
              let cell = tableView.cellForRowAtIndexPath(indexPath) as! MyCell
              // cell is nil when self.tableView.numberOfRowsInSection(section) return 3 for row 1 and 2
              // ... Other stuff
          }
      }
  }
  </code></pre>
  
  <p>I'm not really sure what I'm doing wrong here, I try double checking the indexPath row and section and they are good, numberOfRowsInSection() return 3 but the row 1 and 2 return a nil cell... I can see my 3 cell in the UI too.</p>
  
  <p>Anybody has an idea of what I'm doing wrong?</p>
  
  <p>My function is called after some tableView.reloadData() and in viewDidLoad, is it possible that the tableview didn't finish reloading before my function is executed event though I didn't call it in a dispatch_async ??</p>
  
  <p>In hope of an answer.
  Thank in advance</p>
  
  <p>---------------------------  Answer ------------------------</p>
  
  <p>Additional explanation : </p>
  
  <p>cellForRowAtIndexPath only return visible cell, validation should be done in data model. When the cell is constructed in</p>
  
  <pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  </code></pre>
  
  <p>It should change itself according to the validation state.</p>