title: Fatal error: Array index out of range
body: <p><strong>My Situation:</strong></p>
  
  <p>There is an array called <code>friendCardList</code> claimed in the <code>AppDelegate.swift</code>, and the <code>CardModel</code> is just normal class :</p>
  
  <pre><code>var friendCardList:[CardModel] = []
  </code></pre>
  
  <p>In a <code>UITableViewController</code> called <code>FriendListVC</code>, the elements in the array <code>friendCardList</code> will be listed in the <code>FriendListVC</code>:</p>
  
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let delegate = UIApplication.sharedApplication().delegate as! AppDelegate
      let card = delegate.exchangeListCards[indexPath.row]
      let cell = tableView.dequeueReusableCellWithIdentifier("CardsCell",
      forIndexPath: indexPath) as! BrowserTableViewCell
      return cell
  }
  </code></pre>
  
  <p>I was trying to delete the cell in the <code>FriendListVC</code>:</p>
  
  <pre><code>func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
      let delegate = UIApplication.sharedApplication().delegate as! AppDelegate
      let card = delegate.exchangeListCards[indexPath.row]
      var CardSet = NSMutableSet(array: delegate.exchangeListCards)
      CardSet.removeObject(card)
      delegate.exchangeListCards = CardSet.allObjects as! [CardModel]
  } 
  </code></pre>
  
  <p>My Problem:</p>
  
  <p>When I deleted the cell through sliding the cell to the left, the complier thrown the bug:</p>
  
  <pre><code>fatal error: Array index out of range
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/4I4WY.png" alt="enter image description here"></p>
  
  <p>I blocked up here all the noon.</p>