From 56164f2ce4cf4de892217a1479a555ab99a8d8cf Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 23 Jul 2020 22:44:11 +0200 Subject: [PATCH] 'Fixed' merging errors --- .../persistence/CoreDataBankingPersistence.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift index acf5fb5f..87a059a1 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift @@ -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) }