I am trying to use multiple (two) persistent stores with Core Data for the first time. It seems quite simple to add a store; but once this is done, how do I specify that a request to write (or read) some information to (or from) an entity has to be performed on one store or the other? Some sample code would be welcome, but I can’t find anything on the net.
Asked
Active
Viewed 519 times
0
-
This may help: http://stackoverflow.com/questions/5231775/can-multiple-two-persistent-stores-be-used-with-one-object-model-while-mainta – koen Dec 05 '14 at 17:05
1 Answers
1
Fetches always cover all of the persistent stores managed by the coordinator.
When adding data, you can do either of the following:
- Use configurations in your data model and when adding persistent stores. Configurations define named subsets of your model that contain some but not all entities. If an entity only exists in a configuration that's only used with one persistent store file, then new instances will automatically go to that store.
- If the above doesn't work for your app, you'll need to call
assignObject:toPersistentStore:
to tell the managed object context which store to use.

Tom Harrington
- 69,312
- 10
- 146
- 170
-
I see. How about if I need to make a request on EntityX of StoreOne but ignore EntityX of StoreTwo? For example a counting request (countForFetchRequest). – Michel Dec 06 '14 at 22:32