title: Row deletion doesn't update table view
body: <p>I am loading data into a UITableViewController, the data is coming from Realm. So I have a property on my ViewController: <code>var nextWeekPlants: Results&lt;Plant&gt;!</code>.</p>
  
  <p>The variable is loaded like this: <code>nextWeekPlants = realm.objects(Plant.self).filter("...")</code> in the <code>updateUI()</code> method I wrote. The <code>updateUI()</code> method also calls <code>tableView.reloadData()</code>.</p>
  
  <p>In my <code>numberOfRowsInSection</code> delegate method, I have this check:</p>
  
  <pre><code>if let plants = nextWeekPlants {
      return plants.count
  } else {
      return 0
  }
  </code></pre>
  
  <p>Alright, it works fine collecting the data, showing it on the screen, but as soon as I remove 1 plant from the table view and want to delete another: it crashes.
  <code>'RLMException', reason: 'Index 1 is out of bounds (must be less than 1)'</code></p>
  
  <p>I delete a plant in this way:</p>
  
  <pre><code>tableView.beginUpdates()
  do {
      self.realm.beginWrite()
      self.realm.delete(self.nextWeekPlants[indexPath.row])
      try self.realm.commitWrite()
  } catch (let error) {
      print(error.localizedDescription)
  }
  tableView.deleteRows(at: [indexPath], with: .left)
  tableView.endUpdates()
  </code></pre>
  
  <p>It deletes one plant just fine, but it doesn't delete the other. Do I have to update the tableView in a different way (call <code>updateUI()</code> maybe?) or do I need to update my Realm collection?</p>
  
  <p>** EDIT **</p>
  
  <pre><code>override func viewWillAppear(_ animated: Bool) {
      super.viewWillAppear(animated)
  
      // Little hack to show no extra cells and to make sure the swiping works.
      self.tableView.allowsMultipleSelectionDuringEditing = false
      self.tableView.tableFooterView = UIView()
  
      updateUI()
  }
  
  func updateUI() {
      let calendar = Calendar.current
      let maxDate = calendar.date(byAdding: .day, value: 7, to: Date())
  
      if let nextWeek = maxDate {
           nextWeekPlants = realm.objects(Plant.self).filter("nextWater &lt;= %@", nextWeek)
      }
  
      self.tableView.setEditing(false, animated: true)
      self.tableView.reloadData()
  }
  </code></pre>