开发者

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

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. So these characteristics define what 开发者_高级运维I want the dynamic catalog to be. As such the DynamicCatalog should be created with the attribute Height.

The DynamicCatalogs will also have to be visible in a table so the user can add and remove items to the catalogs.

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. 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?


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. 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.)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜