From 8aa38008d4e2e24700c407c455782975366bcf6a Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 8 Aug 2020 18:17:16 +0200 Subject: [PATCH] Fixed that CoreData didn't keep accounts order --- ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift index 4815273a..5a50bcea 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/Mapper.swift @@ -18,7 +18,7 @@ class Mapper { func map(_ customer: PersistedCustomer) -> Customer { let mapped = Customer(bankCode: map(customer.bankCode), customerId: map(customer.customerId), password: map(customer.password), finTsServerAddress: map(customer.finTsServerAddress), bankName: map(customer.bankName), bic: map(customer.bic), customerName: map(customer.customerName), userId: map(customer.userId), iconUrl: customer.iconUrl, accounts: []) - mapped.accounts = map(mapped, customer.accounts as? Set) + mapped.accounts = map(mapped, customer.accounts?.array as? [PersistedBankAccount]) mappedBanks[mapped] = customer @@ -41,7 +41,7 @@ class Mapper { mapped.userId = customer.userId mapped.iconUrl = customer.iconUrl - mapped.accounts = NSSet(array: map(mapped, customer.accounts, context)) + mapped.accounts = NSOrderedSet(array: map(mapped, customer.accounts, context)) mappedBanks[customer] = mapped @@ -52,7 +52,7 @@ class Mapper { } - func map(_ customer: Customer, _ accounts: Set?) -> [BankAccount] { + func map(_ customer: Customer, _ accounts: [PersistedBankAccount]?) -> [BankAccount] { return accounts?.map( { map(customer, $0) } ) ?? [] }