0

I have an AppIntent (introduced in iOS 16.0) that utilizes my Core Data store. If I enable CoreData's concurrency debugging (add this argument to scheme -com.apple.CoreData.ConcurrencyDebug 1), I get errors while my app is running.

I've begun using background contexts from my container in conjunction with context.performAndWait and am able to avoid the concurrency error.

Is this the right way to use CoreData within an AppIntent, or is there a different pattern I should be leveraging?

stanlemon
  • 399
  • 3
  • 10
  • 1
    It’s hard to be specific without seeing how your code works but in general using `perform` or `performAndWait` is always the right way to use Core Data. – Tom Harrington Dec 29 '22 at 21:58
  • I use `perform` and `performAndWait` always for save and deletes, but this is for fetch requests, which I don't normally wrap in a `perform`. Should I be doing that? – stanlemon Dec 30 '22 at 01:23
  • 1
    @stanlemon Yes, unless you’re certain that your code is running on the main queue *and* you are using a main-queue context. – Tom Harrington Dec 30 '22 at 03:37

0 Answers0