探索Core Data与构建SuperDB应用
1. Core Data中管理对象的删除
在使用获取结果控制器(fetched results controller)时,删除管理对象相对容易。可以通过函数菜单导航到 tableView:commitEditingStyle:forRowAtIndexPath: 方法,该方法的代码如下:
-(void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSManagedObjectContext *context = [self.fetchedResultsController
managedObjectContext];
[context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
NSError *error = nil;
if (![context save:&error]) {
// Replace this implementation with code to handle t
超级会员免费看
订阅专栏 解锁全文
14

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



