diff --git a/Passepartout/Library/Sources/CommonUtils/Business/CoreDataRepository.swift b/Passepartout/Library/Sources/CommonUtils/Business/CoreDataRepository.swift index 03e0d7a4..e9b507bf 100644 --- a/Passepartout/Library/Sources/CommonUtils/Business/CoreDataRepository.swift +++ b/Passepartout/Library/Sources/CommonUtils/Business/CoreDataRepository.swift @@ -205,7 +205,7 @@ private extension CoreDataRepository { @discardableResult func unsafeSendResults(from controller: NSFetchedResultsController) -> [T] { - guard let cdEntities = controller.fetchedObjects else { + guard var cdEntities = controller.fetchedObjects else { return [] } @@ -226,6 +226,9 @@ private extension CoreDataRepository { } do { + cdEntities.removeAll { + entitiesToDelete.contains($0) + } let entities = try cdEntities.compactMap { do { return try fromMapper($0) @@ -243,7 +246,6 @@ private extension CoreDataRepository { return nil } } - if !entitiesToDelete.isEmpty { do { entitiesToDelete.forEach(context.delete)