title: table cells show first index's data of NSMutableArray in swift
body: <p>I have a NSMutableArray (array2) as data source of table view. I want to add object to that array when i select a cell of searchResultsTableView and reload the self.tableView with that array. </p>
  
  <p>If i add object with array2.addObject() method, then all the cells are okay with individual data. </p>
  
  <p>But, if i add object with array2.insertObject(myObject, atIndex: 0), then all the cells show same data as data of array2[0]. Why ? </p>
  
  <p>My problem is in didSelectRowAtIndexPath function of table view. I always want to add the selected object at the first position of my table view, thats why i implemented with insertObject method instead of addObject method. Below is my code portion.</p>
  
  <pre><code>func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          if tableView == self.searchDisplayController!.searchResultsTableView {
              return self.array1.count
          }else{
              return self.array2.count
          }
      }
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
          let cell = UITableViewCell()
          if tableView == self.searchDisplayController!.searchResultsTableView {
              let number = self.array1[indexPath.row]
              cell.textLabel?.text = String(number)
          } else {
              let cell: customCell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as customCell
              let brand = self.array2[indexPath.row] as NSString
              cell.name.text = brand
              cell.comment.text = "100"
          }
  
          return cell
      }
  
      func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
          if tableView == self.searchDisplayController!.searchResultsTableView {
              let cell = tableView.cellForRowAtIndexPath(indexPath) as UITableViewCell!
  
              self.array2.insertObject(cell.textLabel!.text!, atIndex: 0)
              //self.array2.addObject(cell.textLabel!.text!)
  
              self.searchDisplayController!.setActive(false, animated: true)
              self.tableView.reloadData()
          }
      }
  </code></pre>