简体   繁体   English

核心数据动态实体

[英]core data dynamic entities

I want to be able to create a dynamic entity based on attributes that will be defined in another entity. 我希望能够基于将在另一个实体中定义的属性创建动态实体。 For example: 例如:

Entity:Lifeform Attribute->name:String 实体:生命形式属性->名称:字符串

Entity:LifeformCharacteristics Attribute->name:String Attribute->type:String 实体:LifeformCharacteristics属性->名称:字符串属性->类型:字符串

Entity:DynamicCatalog 实体:动态目录

So the characteristics entity will be a entity that will be populated by whatever the user adds. 因此,特征实体将是将由用户添加的内容填充的实体。 An example characteristic could be name:Height type:Number. 特征的一个示例可以是name:Height type:Number。 So these characteristics define what I want the dynamic catalog to be. 因此,这些特征定义了我希望动态目录成为什么。 As such the DynamicCatalog should be created with the attribute Height. 因此,应使用属性Height创建DynamicCatalog。

The DynamicCatalogs will also have to be visible in a table so the user can add and remove items to the catalogs. DynamicCatalogs也必须在表中可见,以便用户可以在目录中添加和删除项目。

I can build and manage the first 2 entities via my DataModel, but the 3rd is dynamic and I'm not sure how to go about it. 我可以通过DataModel来构建和管理前2个实体,但是第3个是动态的,我不确定该怎么做。 I was hoping to use core data to keep the headache of managing data to a minimal. 我希望使用核心数据将管理数据的麻烦降到最低。

This post is the closest thing I've found to an answer, but I'm not sure now to display or reorganize a collection like this: Faking a dynamic schema in Core Data? 这篇文章是我找到的最接近答案的内容,但是我现在不确定要显示或重组这样的集合: 在Core Data中伪造一个动态模式?

Why cause yourself so much trouble? 为什么要给自己造成这么多麻烦?

Consider creating the DynamicCatalog type in Core Data with a 'to many' relationship to something called 'DynamicCatalogValue' or some name that rings the semantic bell. 考虑在Core Data中创建DynamicCatalog类型,该类型与称为“ DynamicCatalogValue”或某些名称的名称之间存在“多对多”关系。 Create attributes on the 'Value' that you will allow the user to describe. 在允许用户描述的“值”上创建属性。 For example (pseudo): 例如(伪):

DynamicValue:
Attribute: userGivenName;
Attribute: userGivenValue;
Attribute: valueType; (e.g. String, Date, etc.)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM