title: Delete all data from specific Realm Object Swift
body: <p>Before i get too far into my question. My goal, which may influence your answers, is to remove <code>Object</code> data if it is no longer in the cloud.</p>
  
  <p>So if I have an array <code>["one", "two", "three"]</code></p>
  
  <p>Then in my server I remove <code>"two"</code></p>
  
  <p>I want my realm to update the change.</p>
  
  <p>I figure the best way to do this is to delete all data in the specific <code>Object</code>, then call my REST API to download the new data. If there is a better way, please let me know.</p>
  
  <p>Okay so here is my problem.</p>
  
  <p>I have an Object <code>Notifications()</code></p>
  
  <p>every time my REST API is called, before it downloads anything I am running this:</p>
  
  <pre><code>let realm = Realm()
  let notifications = Notifications()
  realm.beginWrite()
  realm.delete(notifications)
  realm.commitWrite()
  </code></pre>
  
  <p>I get this error after running: <code>Can only delete an object from the Realm it belongs to.</code></p>
  
  <p>so i tried something like this:</p>
  
  <pre><code>for notification in notifications {
      realm.delete(notification)
  }
  realm.commitWrite()
  </code></pre>
  
  <p>The error I get within xcode is this: <code>"Type Notifications does not conform to protocol 'SequenceType'</code></p>
  
  <p>Not really sure where to go from here.</p>
  
  <p>Just trying to figure out realm. Completely new to it</p>
  
  <p>Note: <code>realm.deleteAll()</code> works, but I don't want all of my realm deleted, just certain <code>Objects</code></p>