Is there a way to "callback" to the main thread once CoreData persistentContainer is complete? Similar to a completion handler? I'd like to update the UI once CoreData is done writing data to my SQLite database.
This is what I have. Once backgroundContext.perform is done, I'd like to callback to the main thread.
let backgroundContext = persistentContainer.newBackgroundContext()
persistentContainer.viewContext.automaticallyMergesChangesFromParent = true
backgroundContext.perform {
//Computationally heavy write to SQLite database. Once complete, callback to main thread
}
I've tried looking at a few different approaches but nothing seems to work or gives weird behavior. Any help would be appreciated.