Core Data 使用排序参数查找项目排序顺序索引
我已从核心数据存储中获取了按“名称”属性排序的项目数组。我的应用程序的用户能够更改项目的名称,并且 UI 应该更新以显示以新方式排序的结果并带有很酷的动画。我遇到的唯一麻烦是在更新项目名称后检索该项目的新订单索引。对于我来说,仅仅为了查找对象新的排序顺序索引而再次获取整个结果集(可能很大...... 1000 多条记录)是否效率低下?
有人能想出更好的方法来完成这项任务吗?
I have fetched an array of items from my core data store sorted by a "Name" property. The user of my app is able to change the name of the item, and the UI is supposed to update to show the results sorted in the new way with a cool animation. The only trouble I'm having is retrieving the new order index of the item after its name is updated. Is it inefficient for me to just fetch the whole result set again (could be quite large... 1000+ records) for the sole purpose of finding the objects new sort order index?
Can anyone think of a better way of accomplishing this task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,这并不是低效,而是它应该的工作方式。如果您有非常大的提取,您可以通过限制提取批量大小、显式提取错误、按属性提取等来提高提取效率。
请参阅 核心数据编程指南:性能了解详细信息。
No, it is not inefficient it is the way it is supposed to work. If you have very large fetches you can make the fetches more efficient by restricting the fetch batch size, explicitly fetching as faults, fetching by attribute etc.
See the Core Data Programming Guide:Performance for details.