|
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 Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
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.