CoreData general question
just needed your expertise in a general coredata Q.
How would u approach this problem?
App (v1.0) with pre-populated data. (model with 8 entities) - (SQLite db) user can read/write in four of them while the rest (4) are read only and are pre-populated) (so far so good) Now App is updated (v1.1) with NEW pre-populated dataset (newSQLite db is provided)(NO CHANGES to the model) How do you approach this and preserve USER data?
my approach开发者_如何学编程:
1.delete the entities (the 4 that are read only) 2.replace them with the new entities 3.theoretically user data are intact. 4.build and run
is there something wrong with this? What would you suggest?
thanks
If the readonly and readwrite entities do not share relationships, the easiest solution is to put each group in their own configuration and then have separate stores. That way, updating is just a matter of swapping out the readonly persistent store file.
If they do have relationships, then your only option is delete all the existing readonly and repopulate by building new objects on the fly.
If you are designing from scratch the first option is usually best for pre-populated material. You can use objectIDs and/or fetched relationships to form pseudo-relationships across stores.
精彩评论