title: Can only delete an object from the Realm it belongs to
body: <p>Im getting this error "<strong>Can only delete an object from the Realm it belongs to</strong>" every time I try to delete an object from realm on my tableview. Here is the relevant code:</p>
  
  <pre><code>let realm = try! Realm()
  var checklists = [ChecklistDataModel]()
  
  override func viewWillAppear(_ animated: Bool) {
  
  
      checklists = []
      let getChecklists = realm.objects(ChecklistDataModel.self)
  
      for item in getChecklists{
  
          let newChecklist = ChecklistDataModel()
          newChecklist.name = item.name
          newChecklist.note = item.note
  
          checklists.append(newChecklist)
      }
  
      tableView.reloadData()
  
  }
  
  override func numberOfSections(in tableView: UITableView) -&gt; Int {
      return 1
  }
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return checklists.count
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "ChecklistCell", for: indexPath) as! ListsTableViewCell
  
      cell.name.text = checklists[indexPath.row].name
      return cell
  }
  
  override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
      if editingStyle == .delete {
  
          // Delete the row from the data source
          try! realm.write {
              realm.delete(checklists[indexPath.row])
          }
  
          //delete locally
          checklists.remove(at: indexPath.row)
  
          self.tableView.deleteRows(at: [indexPath], with: .fade)
      }
  }
  </code></pre>
  
  <p>I know it is this part to be specific:</p>
  
  <pre><code>     // Delete the row from the data source
          try! realm.write {
              realm.delete(checklists[indexPath.row])
          }
  </code></pre>
  
  <p>Any ideas of what is going on?
  Thanks in advance!</p>