【问题标题】:NSFetchedResultsController crash on -controllerDidChangeContent: in iPadNSFetchedResultsController 在 -controllerDidChangeContent 上崩溃:在 iPad 中
【发布时间】:2016-05-04 07:33:42
【问题描述】:

NSFetchedResultsController 在 -controllerDidChangeContent: 插入新记录并保存到persistentStore 时崩溃。

代码:

- (void)controller:(NSFetchedResultsController *)controller
   didChangeObject:(id)anObject
       atIndexPath:(NSIndexPath *)indexPath
     forChangeType:(NSFetchedResultsChangeType)type
      newIndexPath:(NSIndexPath *)newIndexPath {
    NSLog(@"== UPDATING indexPath (%@) newIndexPath (%@) type %i", indexPath, newIndexPath, (int)type);
    switch (type) {
        case NSFetchedResultsChangeDelete: {
            [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
            break;
        }
        case NSFetchedResultsChangeInsert: {
            [self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationBottom];
            break;
        }
        case NSFetchedResultsChangeMove: {
            [self.tableView moveRowAtIndexPath:indexPath toIndexPath:newIndexPath];
            break;
        }
        case NSFetchedResultsChangeUpdate: {
            [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
            break;
        }
        default:
            break;
    }
}

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
    NSLog(@"== BEGIN UPDATING");
    [self.tableView beginUpdates];
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
    NSLog(@"== END UPDATING");
    [self.tableView endUpdates];
}

注意:- 在目标应用程序中,FetchedResults 委托是在 UITableViewController 子类中实现的。 FetchedResultsController 正在处理子托管对象上下文。

【问题讨论】:

  • 您是否收到任何错误日志?如果是,请在此处粘贴。

标签: ios objective-c ipad core-data ios8.3


【解决方案1】:

可能的错误来源(请提供错误信息):

  1. 向 FRC 提供数据的 MOC 不属于 NSMainQueueConcurrencyType
  2. -controller:didChangeSection:atIndex:forChangeType: 未实现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-26
    • 2011-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多