|
I want to get the exchange rate of a currency and put it into a variable as a double. The JSON looks like the following:
|
|
You could do something like this:
I think this should work. I have omitted |
|
With the following code, I get these errors: site/ContentView.swift:54:18: Referencing subscript 'subscript(dynamicMember:)' requires wrapper 'Binding<[CurrencyRates]>' /Users/rmann/Library/Autosave Information/data from web site/data from web site/ContentView.swift:54:26: Value of type '[CurrencyRates]' has no dynamic member 'rates' using key path from root type '[CurrencyRates]' /Users/rmann/Library/Autosave Information/data from web site/data from web site/ContentView.swift:54:31: Cannot convert value of type 'Binding<Subject>' to expected argument type 'Double?' /Users/rmann/Library/Autosave Information/data from web site/data from web site/ContentView.swift:59:1: Initializer 'init(_:)' requires that 'Double' conform to 'StringProtocol' /SwiftUI.Text:4:12: Where 'S' = 'Double'
|
|
As the error messages indicate, Instead, However, looking at Here's your code with tweaks I made to get it to work...
|
|
Also, this bit of code works? :
It is problematic because the Also it is not a good practice to hide complex work inside computed properties because you generally don't expect that accessing |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.