Instance Method

loadPersistentStores(completionHandler:)

Instructs the persistent container to load the persistent stores.

Declaration

func loadPersistentStores(completionHandler block: @escaping (NSPersistentStoreDescription, Error?) -> Void)

Parameters

block

Once the loading of the persistent stores has completed, this block will be executed on the calling thread.

Discussion

Once the persistent container has been initialized, you need to execute loadPersistentStores(completionHandler:) to instruct the container to load the persistent stores and complete the creation of the Core Data stack.

Once the completion handler has fired, the stack is fully initialized and is ready for use. The completion handler will be called once for each persistent store that is created.

If there is an error in the loading of the persistent stores, the NSError value will be populated.

See Also

Configuring a Container

var persistentStoreDescriptions: [NSPersistentStoreDescription]

The persistent store descriptions used to create the persistent stores referenced by this persistent container.

var managedObjectModel: NSManagedObjectModel

The model associated with this persistent container. (read-only)

var name: String

The name of this persistent container. (read-only)

var persistentStoreCoordinator: NSPersistentStoreCoordinator

The persistent store coordinator associated with this persistent container. (read-only)