iphone 核心数据 - 过滤 NSFetchedResultController?
我得到了一个由其他程序员编写的框架来访问核心数据。 在这种情况下,我收到一个预加载的 NSFetchedResultController,我需要对其进行过滤,以显示其部分数据。
这是我尝试过的:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"category==%@", @"current"];
[NSFetchedResultsController deleteCacheWithName:@"Root"];
[myResultController.fetchRequest setPredicate:predicate];
myResultController.fetchedObjects = [myResultController.fetchedObjects filteredArrayUsingPredicate:predicate];
我收到一条错误消息,指出无法设置对象,要么缺少 setter 方法,要么对象是只读的。
那么,过滤已加载的 NSFetchResultController 的最佳方法是什么,而不必将过滤后的数据存储到另一个数组中?
I was given a framework written by other programmers to access the core data.
In this situation i receive a pre-loaded NSFetchedResultController which I need to filter, to display a part of it's data.
Here is what I tried:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"category==%@", @"current"];
[NSFetchedResultsController deleteCacheWithName:@"Root"];
[myResultController.fetchRequest setPredicate:predicate];
myResultController.fetchedObjects = [myResultController.fetchedObjects filteredArrayUsingPredicate:predicate];
And i get an error saying that object cannot be set, either setter method is missing, or object is read-only.
So whats the best way to filter an NSFetchResultController which is already loaded, without having to store the filtered data into another array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
fetchedObjects
是只读的。您无法手动设置它。您需要做的是使用
myResultController
执行新的获取。fetchedObjects
is readonly. You cannot set it manualy.What you need to do is to perform a new fetch with your
myResultController
.