如何对核心数据获取的属性进行排序 [英] How to sort Core Data fetched properties

查看:24
本文介绍了如何对核心数据获取的属性进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

核心数据文档指出:

与 [fetched] 属性关联的 fetch 请求可以有一个排序顺序,因此可以对 fetched 属性进行排序.

The fetch request associated with the [fetched] property can have a sort ordering, and thus the fetched property may be ordered.

如何在 Xcode 的数据模型编辑器中为获取的属性指定排序描述符?我在任何地方都找不到相关领域.我正在为 iPhone 平台开发,如果这有什么不同的话.

How do I specify the sort descriptors for the fetched property in Xcode's data model editor? I can't find a relevant field anywhere. I'm developing for the iPhone platform, if this makes any difference.

如果通过图形模型编辑器无法做到这一点,我该如何修改代码中获取的属性的获取请求,使其具有排序描述符?

If this is not possible via the graphical model editor, how do I go about modifying the fetch request for the fetched property in code so that it has a sort descriptor?

推荐答案

建模工具似乎没有办法在获取请求上设置排序描述符.

The modeling tool doesn't appear to have a way to set the sort descriptors on the fetch request.

应该有可能[1]在加载模型之后但在将其与持久存储协调器关联之前,找到您想要控制排序顺序的获取的属性描述,并将它们的获取请求替换为获取请求设置了排序描述符.

It should be possible[1] to, after loading the model but before associating it with a persistent store coordinator, to find the fetched property descriptions for which you want to control the sort order, and replace their fetch requests with fetch requests that have sort descriptors set on them.

[1] 原则上这应该可行.在实践中,我没有这样做或测试过.

[1] In principle this should work. In practice, I have not done so or tested it.

这篇关于如何对核心数据获取的属性进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆