title: iOS: Delete ALL Core Data Swift
body: <p>I am a little confused as to how to delete all core data in swift. I have created a button with an <code>IBAction</code> linked. On the click of the button I have the following:</p>
  
  <pre><code>let appDel: foodforteethAppDelegate = UIApplication.sharedApplication().delegate as foodforteethAppDelegate
      let context: NSManagedObjectContext = appDel.managedObjectContext
  </code></pre>
  
  <p>Then I've messed around with various methods to try and delete all the core data content but I can't seem to get it to work. I've used removeAll to delete from a stored array but still can't delete from the core data. I assume I need some type of for loop but unsure how to go about making it from the request. </p>
  
  <p>I have tried applying the basic principle of deleting a single row</p>
  
  <pre><code>func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
  
      let appDel: foodforteethAppDelegate = UIApplication.sharedApplication().delegate as foodforteethAppDelegate
      let context:NSManagedObjectContext = appDel.managedObjectContext
  
      if editingStyle == UITableViewCellEditingStyle.Delete {
  
          if let tv = tblTasks {
              context.deleteObject(myList[indexPath!.row] as NSManagedObject)
              myList.removeAtIndex(indexPath!.row)
              tv.deleteRowsAtIndexPaths([indexPath!], withRowAnimation: UITableViewRowAnimation.Fade)
          }
  
          var error: NSError? = nil
          if !context.save(&amp;error) {
              abort()
          }
  
      }
  
  }
  </code></pre>
  
  <p>However, the issue with this is that when I click a button, I don't have the indexPath value and also I need to loop through all the values which I can't seem to do with context. </p>