From 93de8bf252935b47310a6aa51d044707cf5061cb Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 14 Oct 2020 00:45:56 +0200 Subject: [PATCH] Fixed that persistentContainer and therefore context is nil if during login screen app enters background --- .../BankingiOSApp/persistence/CoreDataBankingPersistence.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift index 6155759c..16f71a9f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/CoreDataBankingPersistence.swift @@ -16,8 +16,9 @@ class CoreDataBankingPersistence: IBankingPersistence, ITransactionPartySearcher return persistentContainer!.viewContext }() + func saveContext () { - if context.hasChanges { + if persistentContainer != nil && context.hasChanges { do { try context.save() } catch {