'Fixed' merging errors

This commit is contained in:
dankito 2020-07-23 22:44:11 +02:00
parent c6c8f7b12e
commit 56164f2ce4
1 changed files with 6 additions and 7 deletions

View File

@ -4,18 +4,17 @@ import BankingUiSwift
class CoreDataBankingPersistence: IBankingPersistence, IRemitteeSearcher {
private let persistentContainer: NSPersistentContainer
private let mapper = Mapper()
private var context: NSManagedObjectContext {
return persistentContainer.viewContext
}
private let context: NSManagedObjectContext
init(persistentContainer: NSPersistentContainer) {
self.persistentContainer = persistentContainer
init(context: NSManagedObjectContext) {
self.context = context
// to fix merging / updating cached objects, see Mapper
context.mergePolicy = NSMergePolicy(merge: NSMergePolicyType.mergeByPropertyObjectTrumpMergePolicyType)
}