我正在尝试调试 strange problem I'm having ,我完全不知道从哪里开始。这个问题很简单:
我有一个返回大约 2000 个对象的获取请求,但 batchSize 为 15。因此只有 15 个对象被加载到内存中,其余的在需要时出错。我遇到的问题是,由于某种原因,当获取请求完成时,我的所有对象都立即出现故障。这大约需要 20 秒。我不明白为什么会这样。
这一定意味着我正在以某种方式访问所有这些对象,导致它们全部出错。调用 fetchedResultsController.fetchedObjects.count
是否会导致所有对象出错?
最佳答案
关于 fetchedObjects
的文档是这样说的
If the fetch request has no predicate, then the results array includes all instances of the entity specified by the fetch request.
你想做什么?获取计数的正确方法是这样的:
id <NSFetchedResultsSectionInfo> sectionInfo = [controllers sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
关于objective-c - 调用 NSFetchedResultsController 的 fetchedObjects 属性是否会导致所有对象出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11166407/