如何在没有 NSFetchedResultsController 的情况下缓存 NSFetchRequest 结果?
有没有办法缓存 NSFetchRequest 结果,但不使用 NSFetchedResultsController? 我知道如何设置结果控制器的缓存名称,但在很多情况下我只是从核心数据存储中提取数据并想要缓存它——但不需要结果控制器。关于如何做到这一点有什么想法吗?我在苹果的文档中找不到任何内容。
Is there a way to cache NSFetchRequest results, but without using an NSFetchedResultsController? I know how to set the cache name for the results controller, but in a number of instances I just pull data from my core data store and want to cache it -- but have no need for a results controller. Any ideas on how to do this? I can't find anything in Apple's documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将其保存在 NSArray 内存中。如果您想在应用程序的执行之间进行缓存,则不能。
NSFetchedResultsController
的该部分未发布,并且 Core Data 的内部结构未公开。如果绝对需要缓存,则使用
NSFetchedResultsController
。然而,考虑到 Core Data 的速度和性能,我会质疑缓存的绝对需求。我怀疑其他领域也能取得绩效。
You can keep it in memory in an NSArray. If you want to cache between executions of your application you can't. That portion of the
NSFetchedResultsController
is not published and the internal structure of Core Data is not open.If a cache is absolutely needed then use a
NSFetchedResultsController
.However, considering the speed and performance of Core Data, I would question the absolute need for a cache. I suspect performance can be gained in other areas.