What's a good pattern, if any, to share a piece of Core Data model across iPhone apps the same way I would share code, images and other resources?
I am thinking of developing my model in one app, and then just including it in the other app as a resource. But can't wrap my head around how to do that. Is it sufficient to just include the generated model code files, which I could include as code? But this does not feel right, I think I need the actual data model file too, which is some opaque resource. But say that both of the apps have also other Core Data model objects that I don't want to share across them? (if I do want to share everything, I guess I could share the xcdatamodeld files, but I specifically want to share only an isolated part of the g开发者_StackOverflowraph.)
To make a concrete example, app 1 has model objects A and B that are related, and C and D that are related. A-B, though, are not related to C-D. App 2 has C-D and E-F. I would like to share C-D (the two model objects and their relation) between the apps, the goal being that the schema updates stay in sync between apps. (Sharing only model, not data.)
Since stores are created by merging the models on hand in any particular app, you can mix models however you wish. However, once you create a store with a particular set of model files, you must have those model files always available in the future.
精彩评论