深入探索Core Data:从理论到超级英雄应用开发
1. Core Data中管理对象的删除
在使用获取结果控制器(fetched results controller)时,删除托管对象相对简单。可通过函数菜单导航到 tableView(_:commitEditingStyle:forRowAt IndexPath:) 方法,该方法如下:
Override func tableView(tableView: UITableView, commitEditingStyle:
UITableViewCellEditingStyle, forRowAtIndex indexPath: NSIndexPath){
if editingStyle == .Delete {
let context = self.fetchedResultsControlled.managedObjectContext
context.deleteObject(self.fetchedResultController.objectAtIndexPath(indexPath) as
NSManagedObject)
var error: NSError? = nil
if !context.save(&error) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes th
超级会员免费看
订阅专栏 解锁全文
98

被折叠的 条评论
为什么被折叠?



