I have some confusion about run the CoreData code on the background queue.
There is some methods we can use to perform a CoreData code on the background thread using the NSManagedObjectContext.
viewContext.perform { /*some code will run on the background thread*/ }
viewContext.performAndWait{ /*some code will run on the background thread*/ }
My question here why i should use these functions rather than using the ordinary way for running some code on the background thread using the DispatchQueue
DispatchQueue.global(qos: .background).async {
/*some code will run on the background thread*/
}