title: Deleting all data in a Core Data entity in Swift 3
body: <p>Is there a way to do a batch delete of all data stored in all of the entities in core data?</p>
  
  <p>I read somewhere that in iOS 9 or 10 that apple introduced a way to do batch deletes, but I can't seem to find any good information on it.</p>
  
  <p>Ultimately, I just need a function that goes through an entity, and deletes all of the data in it. Seems like it should be simple enough, but documentation/tutorials for it have proven exceedingly difficult to find.</p>
  
  <p>Any thoughts?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I added the following code into an IBAction attached to a button:</p>
  
  <pre><code>@IBAction func clearAllData(_ sender: AnyObject) {
      let fetch = NSFetchRequest&lt;NSFetchRequestResult&gt;(entityName: "PLProjects")
      let request = NSBatchDeleteRequest(fetchRequest: fetch)
  
      //get the data from core data
      getPLData()
  
      //reload the table view
      tableView.reloadData()
  }
  </code></pre>
  
  <p>This does not seem to work however. If I close down the project and reopen it, the data is still there. I am assuming this is also why the table view doesn't update, because the data is not actually being deleted.</p>