title: UITableView - different rows in sections with same array
body: <p>I have an array which I get its values from a backend, and I have a <code>UITableView</code> with 3 sections and different rows :</p>
  
  <pre><code> override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      // #warning Potentially incomplete method implementation.
      // Return the number of sections.
      return 3
  }
  
  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      // #warning Incomplete method implementation.
      // Return the number of rows in the section.
  
      if section == 1 {
  
          return 2
      } 
      else if section == 2 {
  
          return 1
  
      } else {
  
          return 3
      }
  
  }
  
  
  
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
  
      let myCell: CellTableViewCell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as! CellTableViewCell
  
      // Configure the cell...
  
      if indexPath.section == 1 {
  
          myCell.titleLabel.text = titles[indexPath.row + 3]
  
      }
      else if indexPath.section == 2 {
  
          myCell.textLabel?.text = "Section 2"
  
      }
      else {
  
  
          myCell.titleLabel.text = titles[indexPath.row] // ERROR!
  
      }
  
      return myCell
  }
  
  
  override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
  
      return "Section"
  }
  </code></pre>
  
  <p>I need to have the cells from 2 different sections to get their data from the same array, and I have a section in the middle which should get it's data from a different array. When I run I get this error:</p>
  
  <pre><code>fatal error: Array index out of range
  </code></pre>
  
  <p>my array contains 5 values, it goes like this:</p>
  
  <pre><code> titles = ["1", "2", "3", "4", "5"]
  </code></pre>
  
  <p>PS: I have custom cells for my TableView</p>
  
  <p>Edit: I edited the sections arrangements ( first time I knew that they are indexed from bottom to top), but I still get and error with my last section cells, also there is a very weird behaviour where when I scroll down then back up, section 2 replaces the 3rd cell of section 1, and it gets moved to the bottom of the table !  </p>