Skip to content

Core Data Outside Perform (ARCH9043)

Key swift.async.core-data-outside-perform · Severity warning · Category async

Flags managed object context fetch / save called from an async function outside context.perform { }.

func load() async throws { let rows = try context.fetch(request) }
func load() async throws { let rows = try await context.perform { try self.context.fetch(request) } }

Wrap context access in await context.perform { } - contexts are bound to their queue.