Удалить данные из Coredata Swift

В моем tableViewController у меня есть следующее. И я пытаюсь удалить элемент для работы.

var myData: Array<AnyObject> = []

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> 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
}

Затем попытаться удалить, у меня есть.

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
    }
}

Ответы на вопрос(7)

Ваш ответ на вопрос