`ordered'标志在一对多关系中做什么? [英] What does the `ordered` flag do in a to-many relationship?

查看:141
本文介绍了`ordered'标志在一对多关系中做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在寻找在Core Data模型中添加一个有序对多关系的方法时,尽可能少地对模型进行了更改,我注意到一个多对多关系的选项,表示有序(见下面的屏幕截图)。哇,听起来不错,但是它做什么?

While looking for ways to add an ordered to-many relationship to my Core Data model, with the least possible amount of changes to the model, I noticed an option of the to-many relationship that says ordered (see screenshot below). Wow, sounds great, but what does it do?

我的SQLite存储不是抱怨,当我检查或取消选中它,我的应用程序仍然编译和运行良好。我认为也许轻量级的移植照顾的变化,但从它的外观,所有我的自定义 NSManagedObject 子类工作,而不需要修改,所以发生了什么?

My SQLite store is not complaining when I check or uncheck it, and my app still compiles and runs fine too. I was thinking maybe the lightweight migration takes care of the change, but from the looks of it, all my custom NSManagedObject subclasses work without the need for modification too, so what's going on?

总结问题:


  • 如果有序的标志将 NSSet 更改为 NSArray 的多对数关系的数据类型?

  • 还是只是修改集合的顺序会持续到连续读取和写入吗?


  • Should that ordered flag change the to-many relationship's data type from NSSet to NSArray?
  • Or is it just that the order in which the set is modified, will persist on sequential reads and writes?
  • Or am I wrong with my assumptions and is it something else entirely?
  • Is there an Apple doc page where this feature is described?

非常感谢!

推荐答案

有序关系允许为相关对象分配任意顺序。

Ordered relationships allow you to assign an arbitrary ordering to related objects. You can think of this as ordering colors from your most to least favorite, rather than sorting by date, title, etc.

在添加此功能之前,排序是通过创建位置属性,然后每当用户重新排序它们时手动更新项目的位置索引。如果你有大量的项目,使用内置的排序可能比手动实现更昂贵,如上所述。

Before this feature was added ordering was implemented by creating a position attribute, then manually updating the position indexes for items whenever the user reordered them. If you have a large number of items, using the built in ordering can be more expensive than implementing this manually, as described above.

这篇关于`ordered'标志在一对多关系中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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