【发布时间】:2015-03-15 19:13:33
【问题描述】:
我是 Swift 的新手, 如何使用 Swift 在 CoreData 中使用 MagicalRecord 删除一行 tableview。
我写过这样的代码,但不工作。我该如何解决这个问题。
override func tableView(tableView: UITableView, commitEditingStyle editingStyle :UITableViewCellEditingStyle,
forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
var aCantact=contactArray[indexPath.row]
aCantact.MR_deleteEntity()
contactArray.removeAtIndex(indexPath.row)
NSManagedObjectContext.MR_defaultContext().MR_saveOnlySelfAndWait()
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Bottom)
tableView.reloadData()
}
}
【问题讨论】:
标签: ios swift ios8 magicalrecord