You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you should update the getAccountBalances method to this once here and safely unwrap arrayOfCryptoBalances since it will lead to a fatal crash in case a user has once set up the API correctly but then deletes the keys on the website and comes back to the App. This here at least won't lead to the App crashing:
public func getAccountBalances(completion: @escaping (ResponseType) -> Void) {
let apiType = Kraken.API.getAccountBalance
if apiType.checkInterval(response: store.balanceResponse) {
completion(.cached)
} else {
krakenDataTaskFor(api: apiType) { (response) in
guard let json = response.json as? Dictionary<String, Any> else {
print("Error: Cast Failed in \(#function)")
return
}
if let arrayOfCryptoBalances = json["result"] as? Dictionary<String,String> {
var balances: [Balance] = []
for cryptoBalance in arrayOfCryptoBalances {
let newBalance = ["type": cryptoBalance.key,
"amount": cryptoBalance.value,
"available": cryptoBalance.value]
balances.append(Balance(json: newBalance, currencyStore: self))
}
self.store.balances = balances
self.store.balanceResponse = response.httpResponse
completion(.fetched)
}
}.resume()
}
}
The text was updated successfully, but these errors were encountered:
Hey,
you should update the getAccountBalances method to this once here and safely unwrap
arrayOfCryptoBalances
since it will lead to a fatal crash in case a user has once set up the API correctly but then deletes the keys on the website and comes back to the App. This here at least won't lead to the App crashing:The text was updated successfully, but these errors were encountered: