Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can two managed object context share one single persistent store coordinator?

Example: I have one persistent store coordinator which uses one single persistent store.

Now there are two managed object contexts, and both want to use the same persistent store. Could both simply use the same persistent store coordinator, or would I have to create two instances of NSPersistentStoreCoordinator? And if I had to, then: Would I also have to create two NSPersistentStore instances?

like image 984
dontWatchMyProfile Avatar asked Dec 15 '25 09:12

dontWatchMyProfile


1 Answers

The Core Data on iPhone article on ADC gives a good introduction to this topic:

In any application, you might have multiple managed object contexts. You might want to maintain discrete sets of managed objects and edits to those objects; or you might want to perform a background operation using one context while allowing the user to interact with objects in another. Each of these would be connected to the same coordinator.

A Persistent Store Coordinator is designed to handle multiple contexts

like image 196
Martin Brugger Avatar answered Dec 16 '25 22:12

Martin Brugger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!