title: Realm accessed from incorrect thread - Swift 3
body: <p>At the top of my <code>UITableViewController</code> is the following: </p>
  
  <pre><code>let queue = DispatchQueue(label: "background")
  </code></pre>
  
  <p>When a task is deleted, the following executes:</p>
  
  <pre><code>self.queue.async {
      autoreleasepool {
          let realm = try! Realm()
          realm.beginWrite()
          realm.delete(task)
          do {
              try realm.commitWrite()
          } catch let error {
              self.presentError()
          }
      } 
   }
  </code></pre>
  
  <p>And then I receive the error</p>
  
  <blockquote>
    <p>terminating with uncaught exception of type
    realm::IncorrectThreadException: Realm accessed from incorrect thread.</p>
  </blockquote>
  
  <p>How could I fix this?</p>