I want to start learning to use NSAsynchronousFetchRequest
by referring to
I even try to execute some simple project from https://github.com/abhishekbedi1432/Core-Data-Asynchronous-Fetching/tree/master which is using NSAsynchronousFetchRequest
.
If I do not enable -com.apple.CoreData.ConcurrencyDebug 1
, the sample project from github able to perform asynchronous fetch without issue. However, once the -com.apple.CoreData.ConcurrencyDebug 1
is enabled, it will also be getting the same fatal error.
CodePudding user response:
You have to make a new context either a child or a root parent for present Core Data container, like so:
let backgroundContext = persistentContainer.newBackgroundContext()
backgroundContext.parent = persistentContainer.viewContext
Exhaustive explanation of using multiple contexts is here.
CodePudding user response:
For me, the async fetch request works as expected when I provide an estimatedResultCount
value to it.