【发布时间】:2016-06-15 13:52:56
【问题描述】:
我在从核心数据中删除记录时收到EXC_BAD_INSTRUCTION Error。这是代码:
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
//deleteIncidents()
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let context:NSManagedObjectContext = appDel.managedObjectContext
context.delete(candles[indexPath.row] as! NSManagedObject)
candles.removeAtIndex(indexPath.row)
do{
try context.save()
}
catch{
}
//tableView.reloadData()
// remove the deleted item from the `UITableView`
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
}
}
【问题讨论】:
标签: ios swift uitableview core-data