Core data 使用coredata中的filterpredicate选择nsmanagedobject的子集
有一个具有Coredata数据模型的项目。每个类都与类型有关系。类型包含一个属性“content”,以及其他属性 它可以用这样的关系来建模Core data 使用coredata中的filterpredicate选择nsmanagedobject的子集,core-data,nsmanagedobject,Core Data,Nsmanagedobject,有一个具有Coredata数据模型的项目。每个类都与类型有关系。类型包含一个属性“content”,以及其他属性 它可以用这样的关系来建模 Element dimensions colors ... Colors type----->ColorType content Dimension quantity unit type ----->DimensionType content
Element
dimensions
colors
...
Colors
type----->ColorType
content
Dimension
quantity
unit
type ----->DimensionType
content
Unit
type ----->UnitType
content
...
ObjectX
type ----->TypeX
content
与其有很多类型,我更喜欢以下类型
Super
type -----> Type
content
Unit isa Super
Dimension isa Super
...
ObjectX isa Super
检索nsmanagedobjects的子集似乎很简单,其中属性包含匹配的字符串,例如通过FilterPredicate检索属性ownersClassname
Super
type -----> Type
content
ownersClassName
尺寸类型可能为“长度”、“宽度”、“高度”
颜色类型可能是“十六进制”、“rgb”、“cymk”
单位类型可以是“毫米”、“厘米”、“英寸”等
元素可能有一到多个维度、颜色等,用户不需要键入“mm”、“rgb”,因此需要特定的下拉设置。而且需要灵活地预测模型中的变化,否则会破坏DBMS
问题是:
当用户添加新类型时,如何将此ownersClassName字符串设置为“Unit”、“Dimension”、“Color”,以便FilterPredicate可以首先进行筛选…您可以在模型类的
唤醒期间为关系设置默认对象值
可以缓存默认值,这样就不会在每次插入时从存储中重新蚀刻对象