In my application, I have a NSFetchedResultsController
to load Core Data objects in a UITableView.
The fetch request associated with this FRC uses the new vie
Not worked for me, So I changed save block from
self.persistentContainer.performBackgroundTask { (context) ... }
to
self.persistentContainer.newBackgroundContext().performAndWait { ... }
and of corse setting true automaticallyMergesChangesFromParent
to make auto merge work.
lazy var viewContext: NSManagedObjectContext = {
self.persistentContainer.viewContext.automaticallyMergesChangesFromParent = true
self.presistentContainer.viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump
return self.persistentContainer.viewContext
}()
I don't know why the context
from performBackgroundTask
not merged to viewContext
.