Instance Method

performBackgroundTask(_:)

Causes the persistent container to execute the block against a new private queue context.

Declaration

func performBackgroundTask(_ block: @escaping (NSManagedObjectContext) -> Void)

Parameters

block

A block that is executed by the persistent container against a newly created private context. The private context is passed into the block as part of the execution of the block.

Discussion

Each time this method is invoked, the persistent container creates a new NSManagedObjectContext with the concurrencyType set to NSManagedObjectContextConcurrencyType.privateQueueConcurrencyType. The persistent container then executes the passed in block against that newly created context on the context’s private queue.

See Also

Accessing the Context(s)

func newBackgroundContext() -> NSManagedObjectContext

Creates a private managed object context.

var viewContext: NSManagedObjectContext

The managed object context associated with the main queue. (read-only)

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software