Reputation: 47
My project have multiple .sqlite .
Im using 1 context , 1 persistentStoreCoordinator, linked to multiple persistentStores.
I wonder does [context assignObject : toPersistentStore]
no need to call [context save] after ?
what if the object A have 5 relationships to object B C D E F
Do i need to call . [context assignObject : B ..]
[context assignObject : C ..]
... (and so on) ?? In order to save a whole branch of data ???
Upvotes: 0
Views: 101
Reputation: 6635
According to the documentation, you need to call that method if you have multiple writable persistent stores that can store that entity type.
If the entity can only be saved in one of the stores, then it will be automatically assigned to that persistent store. If you have a whole chain of related entities, yes, you'll need to assign each one. You can't have relationships between entities in different stores, so watch out for that.
Finally, you'll still need to call save
on the managed object context to persist those entities. Assigning them to a store doesn't save, it just determines where they will be saved by the context when the time comes.
Upvotes: 1