Contents

performBackgroundTask(_:)

Executes a closure on a private queue using an ephemeral managed object context.

Declaration

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

Parameters

  • block:

    A closure 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.

Mentioned in

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

Performing Background Tasks