title: swift update cell accessory type
body: <p>I am trying to update my table cell accessory type when I tap a cell.
  here is the code:</p>
  
  <pre><code>var selectedCellArray :[FriendTableViewCell] = []
  var friends: [PFUser] = []
  
  
  
      override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      var  selectedCell = self.tableView(tableView, cellForRowAtIndexPath: indexPath) as FriendTableViewCell
  
      if (selectedCell.accessoryType == UITableViewCellAccessoryType.None){
  
          selectedCell.accessoryType = .Checkmark
          selectedCellArray.append(selectedCell)
      }else if (selectedCell.accessoryType == UITableViewCellAccessoryType.Checkmark){
  
          selectedCell.accessoryType = .None
          var index = 0
          for cell in selectedCellArray{
              if (cell != selectedCell){
                  index++
              }else{
                  break
              }
          }
  
          selectedCellArray.removeAtIndex(index)
  
  
      }
      self.tableView(tableView, cellForRowAtIndexPath: indexPath)
  
  
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      var cell = tableView.dequeueReusableCellWithIdentifier("friend") as? FriendTableViewCell ?? FriendTableViewCell()
      var round = 0
      var friend: AnyObject = self.friends[indexPath.row]
  
  
      cell.firstNameLabel.text = friend["firstName"] as? String
  
      cell.lastNameLabel.text = friend["lastName"] as? String
      println(selectedCellArray)
      round++
      var hasFound = false
      if (self.checkSelectedArray(selectedCellArray, target: cell)){
          cell.accessoryType = .Checkmark
      }else{
          cell.accessoryType = .None
      }
  
      cell.firstNameLabel.sizeToFit()
      cell.lastNameLabel.sizeToFit()
      return cell
  }
  func checkSelectedArray(selectedArray:[FriendTableViewCell], target:FriendTableViewCell) -&gt; Bool{
      for cell in selectedCellArray{
          if cell.isEqual(target){
              return true
          }
      }
      return false
  }
  </code></pre>
  
  <p>Also, is there a built-in method like array.contain? Currently, I wrote a function by myself to check if an array has certain element......</p>
  
  <p>Please help me out... I am stuck for this problem for about 8 hours</p>