Sunday, December 25, 2022
HomeiOS Developmentios - characterize a JSON file in SwiftUI?

ios – characterize a JSON file in SwiftUI?


I am fairly a newbie and attempting to get the OpenWeather API JSON to point out up in my problem challenge.

I managed to mannequin it


struct WeatherRespose: Codable {
    var climate: [Weather]
    var identify: String
}

&

import Basis


struct Climate: Hashable, Codable {
    var predominant: String
    var description: String
}

Along with fetch the info in ContentView. Nonetheless, when I attempt to current it:

@State var weatherForcast = Climate() or @State var weatherForcast = WeatherResponse() I get this error: Lacking argument for parameter ‘from’ in name, insert ‘from: <#Decoder#>’

The one factor that labored for me is to current the info in an array:

@State var weatherForcast = [Weather]()

Any thought what am I lacking? thanks a lot! Ran



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments