assign(_:to:)
Specifies the store in which a newly inserted object will be saved.
Declaration
func assign(_ object: Any, to store: NSPersistentStore)Parameters
- object:
A managed object.
- store:
A persistent store.
Discussion
You can obtain a store from the persistent store coordinator, using for example persistentStore(for:).
Special Considerations
It is only necessary to use this method if the receiver’s persistent store coordinator manages multiple writable stores that have object‘s entity in their configuration. Maintaining configurations in the managed object model can eliminate the need for invoking this method directly in many situations. If the receiver’s persistent store coordinator manages only a single writable store, or if only one store has object’s entity in its model, object will automatically be assigned to that store.