title: Have error "Invalid update: invalid number of rows" when I already updated the data
body: <p>my code looks like this:</p>
  
  <pre><code>func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
  
      let IndexPaths = NSArray(array:[indexPath])
  
      let plistPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
      let path = plistPath.appending("/ClassA.plist")
      self.listClasses.remove(at:indexPath.row)
      self.listClasses?.write(toFile: path, atomically: false)
      tableView.reloadData()
      self.tableView.deleteRows(at: IndexPaths as! [IndexPath], with: .fade)
  }
  </code></pre>
  
  <p>I know that if I did not update the data from my data source it would cause problems, so I added these two lines before I update my data in the TableView.</p>
  
  <pre><code>self.listClasses.remove(at:indexPath.row)
  self.listClasses?.write(toFile: path, atomically: false)
  </code></pre>
  
  <p>But it still doesn't work. I still received this error</p>
  
  <blockquote>
    <p>'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (6) must be equal to the number of rows contained in that section before the update (6), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).</p>
  </blockquote>
  
  <p>Does anyone know why that happened?</p>
  
  <p>Below is my code for TableView</p>
  
  <pre><code>@IBAction func Edit(_ sender: Any) {
      setEditing(true, animated: true)
  }
  
  func tableView(_ tableView:UITableView, numberOfRowsInSection     selection:Int) -&gt; Int {
      return self.listClasses.count
  }
  
  public func tableView(_ tableView: UITableView, cellForRowAt indexPath:IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "cellIdentifier", for: indexPath as IndexPath)
      let row = indexPath.row
  
      let rowDict = self.listClasses[row] as! NSDictionary
  
      cell.textLabel?.text = rowDict["name"] as? String
      return cell
  }
  
  override func viewDidLoad() {
      // Do any additional setup after loading the view, typically from a nib.
      super.viewDidLoad()
  
      let plistPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
      let path = plistPath.appending("/ClassA.plist")
      let fileManager = FileManager.default
      if (!(fileManager.fileExists(atPath: path)))
      {
          let bundle : String = Bundle.main.path(forResource: "ClassA", ofType: "plist")!
          do {
              try fileManager.copyItem(atPath: bundle as String, toPath: path)
          }
          catch {
              NSLog("Error!")
          }
      }
      self.listClasses = NSMutableArray(contentsOfFile:path)
  
      //set up the textfield
      self.txtField.isHidden = true
      self.txtField.delegate = self
  
  }
  
  override func setEditing(_ editing: Bool, animated: Bool) {
      super.setEditing(editing, animated: animated)
      self.tableView.setEditing(editing, animated:true)
  }
  </code></pre>
  
  <p>//update
  Now I deleted "tableView.reloadData()"</p>
  
  <pre><code>    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
  
      let IndexPaths = NSArray(array:[indexPath])
  
      let plistPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
      let path = plistPath.appending("/ClassA.plist")
      self.listClasses.remove(at:indexPath.row)
      self.listClasses?.write(toFile: path, atomically: false)
      self.tableView.deleteRows(at: IndexPaths as! [IndexPath], with: .fade)
  }
  </code></pre>
  
  <p>But it still doesn't work.</p>