title: Dynamic viewForHeaderInSection and multiple cellForRowAtIndexPath
body: <p>I'm trying to make a custom cell to be the Section of my cells:</p>
  
  <p><a href="https://i.stack.imgur.com/jpCEP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jpCEP.png" alt="enter image description here"></a></p>
  
  <p>For this I'm overriding some functions like:</p>
  
  <blockquote>
    <p>numberOfRowsInSection</p>
    
    <p>viewForHeaderInSection</p>
    
    <p>heightForHeaderInSection</p>
  </blockquote>
  
  <p>And I'm working with multiple <code>cellForRowAtIndexPath</code> I'm using a <code>if indexPath.row</code> to identify the <code>Cell</code> and populate them in a dynamic way.</p>
  
  <pre><code>import UIKit
  
  class TesteTableViewController: PFQueryTableViewController {
  
  
  override func preferredStatusBarStyle() -&gt; UIStatusBarStyle {
      return UIStatusBarStyle.LightContent
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
      loadCollectionViewData()
  
  }
  
  
  func loadCollectionViewData() {
  
      // Build a parse query object
      let query = PFQuery(className:"Feed")
  
      // Check to see if there is a search term
  
  
      // Fetch data from the parse platform
      query.findObjectsInBackgroundWithBlock {
          (objects: [PFObject]?, error: NSError?) -&gt; Void in
  
          // The find succeeded now rocess the found objects into the countries array
          if error == nil {
  
              print(objects!.count)
              // reload our data into the collection view
  
  
          } else {
              // Log details of the failure
  
          }
      }
  }
  
  
  override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      // #warning Incomplete implementation, return the number of sections
      return objects!.count
  }
  
  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return 1
  }
  
  
  override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
      var header = tableView.dequeueReusableCellWithIdentifier("Cell2")! as! TesteTableViewCell
  
  
      return header
  }
  
  override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -&gt; CGFloat {
      return 30.0
  }
  
  
  // Initialise the PFQueryTable tableview
  override init(style: UITableViewStyle, className: String!) {
      super.init(style: style, className: className)
  }
  
  required init(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)!
  
      // Configure the PFQueryTableView
      self.parseClassName = "Feed"
      self.pullToRefreshEnabled = true
      self.paginationEnabled = false
  }
  
  
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
  var cell: TesteTableViewCell!
      let object = objects![indexPath.section]
  if indexPath.row == 0 {
  cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! TesteTableViewCell
  
  
  
  
  // Extract values from the PFObject to display in the table cell
  if let nameEnglish = object["name"] as? String {
  cell?.label1?.text = nameEnglish
  
  }
  
  
  }
  else{
  cell = tableView.dequeueReusableCellWithIdentifier("Cell2", forIndexPath: indexPath) as! TesteTableViewCell
  
  
      // Extract values 2from the PFObject to display in the table cell
      if let nameEnglish2 = object["brief"] as? String {
          cell?.label2?.text = nameEnglish2
  
  
      }
  
  }
  
  return cell
  }
  
  }
  </code></pre>
  
  <p>With my code I have this result:</p>
  
  <p><a href="https://i.stack.imgur.com/mhQ4E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mhQ4E.png" alt="enter image description here"></a></p>
  
  <p>I'm successfully populating both Cells with different Identifiers.</p>
  
  <p>But look like this function is called before the <code>cellForRowAtIndexPath</code> and it return the content that I have in the storyBoard and not the content that I'm populating dynamically.</p>
  
  <pre><code>override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
      var header = tableView.dequeueReusableCellWithIdentifier("Cell2")! as! TesteTableViewCell
  
  
      return header
  }
  </code></pre>
  
  <p>And I really think that is my problem. (The order that things happen).</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks.</p>