iOS 高效过滤 NSFetchedResultsController
我正在尝试向 Core Data 支持的 UITableView
添加搜索支持,并开始遇到一些性能问题。我目前与两个 NSFetchedResultsController
关联(一个用于常规,一个用于搜索)。在我的 UISearchDisplayDelegate 方法中,我在每次调用后释放并重新创建我的 NSFetchedResultsController 。但是,这会导致打字时出现延迟!是否有更有效的方法来过滤 NSFetchedResultsController
?我已将批量大小设置为大约 50 个项目,并且我的数据库有几千条记录(如果这有影响的话)。谢谢!
I'm attempting to add search support to a Core Data backed UITableView
and started to hit some performance issues. I currently have associations to two NSFetchedResultsController
(one for regular and one for searching). In my UISearchDisplayDelegate
methods I release and recreate my NSFetchedResultsController
after each call. However, this causes lag while typing! Is there a more efficient way to filter an NSFetchedResultsController
? I've setup my batch size to around 50 items and my database has a few thousand records if that makes a difference. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
NSFetchedResultsController
文档 使其成为可能很清楚:fetchRequest
属性。请注意,您不能简单地修改现有的获取请求;您必须创建一个新的。-executeFetch:
。The
NSFetchedResultsController
documentation makes it pretty clear:fetchRequest
property. Note that you cannot simply modify the existing fetch request; you must create a new one.-executeFetch:
.我使用以下代码来过滤 FetchedResultController 的结果
希望有帮助!
I use the following code to filter the results of the FetchedResultController
Hope that helps!
是的,您可以:
创建 NSFetchRequest 实例并每次更改其排序描述符:
阅读苹果文档: https ://developer.apple.com/reference/coredata/nsfetchedresultscontroller
Yes you can:
Create the NSFetchRequest instance and change its sort descriptor each time:
Read the apple document: https://developer.apple.com/reference/coredata/nsfetchedresultscontroller