diff Simoleon/Helpers/CurrencySelector.swift @ 150:6eac99e99b96

Add error handling to read json function
author Dennis Concepcion Martin <dennisconcepcionmartin@gmail.com>
date Thu, 19 Aug 2021 19:12:56 +0100
parents 87f02d4f9c26
children 2584fd74235a
line wrap: on
line diff
--- a/Simoleon/Helpers/CurrencySelector.swift	Thu Aug 19 19:12:31 2021 +0100
+++ b/Simoleon/Helpers/CurrencySelector.swift	Thu Aug 19 19:12:56 2021 +0100
@@ -19,8 +19,6 @@
     @State private var alertMessage = ""
     @State private var showingAlert = false
     
-    var currencyPairs: [CurrencyPairModel] = parseJson("CurrencyPairs.json")
-    
     /*
      If searched currency string is empty:
      * Show all currencies
@@ -28,6 +26,7 @@
      * Show filtered list of currencies containing searched currency string
      */
     var searchResults: [CurrencyPairModel] {
+        let currencyPairs: [CurrencyPairModel] = try! read(json: "CurrencyPairs.json")
         if searchCurrency.isEmpty {
             return currencyPairs.sorted { !$0.isLocked && $1.isLocked }
         } else {