开发者

Two different managedObjects and one sqlite database?

I am trying to create two tables within the same sqlite database. Now, this two managedObjectModels don't run in the same instance. Let me explain...I run the application once, and I create the managedObject in the persistent store, programmatically. Let say I have 5 attributes for that one. Then I run it again and I create a new managedObject in the persistent store, but this time I only use 3 attributes...how can I make this possible? Right now it crashes because the amount o开发者_JAVA技巧f attributes don't match.

Regards and thanks!


The simplest answer is to not create your data model programmatically. It should be created at design-time and not modified. Instead, you should design your data model to be flexible enough to meet your needs. For instance, instead of creating one entity with a variable number of attributes, create two entities, one with a one-to-many relationship to the other, and store what information would have gone in your variable number of attributes there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜