title: Delete Data from Coredata Swift
body: <p>In my tableViewController I have the following.  And I am trying to get delete an item to work.</p>
  
  <pre><code>var myData: Array&lt;AnyObject&gt; = []
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let cellID: NSString = "Cell"
      var Cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellID) as UITableViewCell
      var data: NSManagedObject = myData[indexPath.row] as NSManagedObject
      Cell.textLabel?.text = data.valueForKeyPath("Name") as? String
  
      return Cell
  }
  </code></pre>
  
  <p>Then to try and delete I have. </p>
  
  <pre><code>override func tableView(tableView: (UITableView!), commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
      if editingStyle == .Delete {
          let cellID: NSString = "Cell"
          var Cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(cellID) as UITableViewCell
          var data: NSManagedObject = myData[indexPath.row] as NSManagedObject
          data.delete(0)
  
          // Delete the row from the data source
          //tableView!.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
  
  
      } else if editingStyle == .Insert {
          // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
      }
  }
  </code></pre>