title: Index Out of Range when deleting from TableView?
body: <p>Just as a heads up I am using Firebase to store/remove data.</p>
  
  <p>Here is my viewDidLoad code:</p>
  
  <pre><code> override func viewDidLoad()
  {
      super.viewDidLoad()
  
      observePeople()
  
      tableView.delegate = self
      tableView.dataSource = self
  
  }
  </code></pre>
  
  <p>The observePeople() method operates like this (I reload the table twice here)</p>
  
  <pre><code> func observePeople()
  {
      let ref = FIRDatabase.database().reference().child("Users")
      ref.observeEventType(.ChildAdded, withBlock:
      { (snapshot) in
  
          if let firstname = snapshot.value?.objectForKey("firstname"), lastname = snapshot.value?.objectForKey("lastname")
          {
              let fullname = "\(firstname) \(lastname)"
              self.names.append(fullname)
  
              dispatch_async(dispatch_get_main_queue())
              {
                  self.tableView.reloadData()
              }
          }
  
      }, withCancelBlock: nil)
  
      ref.observeEventType(.ChildRemoved, withBlock:
      { (snapshot) in
  
      if let firstname = snapshot.value?.objectForKey("firstname"), lastname = snapshot.value?.objectForKey("lastname"), dateOfBirth = snapshot.value?.objectForKey("Date of Birth"), zipcode = snapshot.value?.objectForKey("Zipcode")
      {
          print("We deleted the person \(firstname) \(lastname) with the details: \(dateOfBirth), \(zipcode)")
          self.tableView.reloadData()
      }
  
      }, withCancelBlock: nil)
  }
  </code></pre>
  
  <p>And in my viewDidAppear I refresh the table again:</p>
  
  <pre><code>override func viewDidAppear(animated: Bool)
  {
      tableView.reloadData()
  }
  </code></pre>
  
  <p>Lastly, I once I delete the row I get the error saying the index is out of range. What is interesting is when I populate my table with 4 items, if I delete the first item it'll ACTUALLY delete the second item, and if i delete the third one it'll actually delete the fourth one, and so on. I've been adding breakpoints to observe this phenomenon the best I can and it breaks right after I remove it from the tableview.</p>
  
  <pre><code>override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
  {
      if editingStyle == .Delete
      {
          let ref = FIRDatabase.database().reference().child("Users")
          ref.observeEventType(.ChildAdded, withBlock: { (snapshot) in
  
              if let firstname = snapshot.value?.objectForKey("firstname"), lastname = snapshot.value?.objectForKey("lastname")
              {
                  let fullname = "\(firstname) \(lastname)"
                  let currentName = self.names[indexPath.row]
  
                  if fullname == currentName
                  {
                      print("We have a match")
                      let currentKey = snapshot.key
                      ref.child(currentKey).removeValue()
  
                      dispatch_async(dispatch_get_main_queue())
                      {
                          self.tableView.reloadData()
                      }
                  }
  
              }
  
              }, withCancelBlock: nil)
      }
  
          names.removeAtIndex(indexPath.row)
          tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
      }
  }
  </code></pre>
  
  <p>So right after the tableView.deleteRows method I'm getting the error. Been at this for a while and can't seem to locate it. Also, I always make sure the arrays match up for the database and the array so they're both empty at the same time before I populate them.</p>