title: Delete @ObservedRealmObject in SwiftUI View
body: <p>I am using Realm to persist a data on the device.</p>
  <p><strong>Question</strong>: What is the correct implementation to delete an object view using  <code>@ObservedRealmObject</code> property?</p>
  <p>Here is a simplified implementation of the view:</p>
  <pre><code>import RealmSwift
  import SwiftUI
  
  struct ContentView: View {
      @ObservedResults(Item.self) var items
  
      var body: some View {
          NavigationView {
              List {
                  ForEach(items) { item in
                      NavigationLink(destination: ItemDetailView(item: item)) {
                          Text(item.name)
                      }
                  }
              }
          }
      }
  }
  
  struct ItemDetailView: View {
      @ObservedRealmObject var item: Item
  
      var body: some View {
          Text(item.name)
              .onTapGesture {
                  let realm = Realm()
  
                  try! realm.write {
                      realm.delete(item)
                  }
              }
      }
  }
  </code></pre>
  <p><strong>Expectation</strong>: Item is deleted and screen navigates back to list</p>
  <p><strong>Result</strong>: The item is being deleted, however, the exception below is being thrown:</p>
  <pre><code>This method may only be called on RLMArray instances retrieved from an RLMRealm
  </code></pre>
  <p>I have tried to delete <code>@ObservedRealmObject</code> which will give an expected result, however I will be losing a property which allows the <code>ItemDetailView</code> to &quot;know&quot; when the object has changed regardless of where that change happened.</p>