OpenWeatherMap API每小时预测不可用

发布于 2025-02-06 10:21:58 字数 854 浏览 0 评论 0原文

在我的天气应用程序中,我在文本字段中调用天气预报,但我会收到错误:在调用initializer中没有确切的匹配。

这是可能相关的代码:

ScrollView(.horizontal){
    HStack(spacing: 5.0) {
        ForEach(0..<25) {_ in
            VStack{
                Text([weather.hourly.hourly]) //Error
                    .bold()
                    .font(.subheadline)
                    .frame(width: 105, height: 15)
            }
        }
    }
}
struct OneCall: Decodable {
    let lat, lon: Double
    let timezone : String
    let timezone_offset : Int
    let current: CurrentResponse
    let hourly: HourlyResponse
    struct HourlyResponse: Decodable{
        let sunrise: Date?
        let sunset: Date?
        var hourly: Array<CurrentResponse>
    }

In my weather app, I call the weather forecast in a text field but I get the error: No exact matches in call to initializer.

Here is the code that might be related:

ScrollView(.horizontal){
    HStack(spacing: 5.0) {
        ForEach(0..<25) {_ in
            VStack{
                Text([weather.hourly.hourly]) //Error
                    .bold()
                    .font(.subheadline)
                    .frame(width: 105, height: 15)
            }
        }
    }
}
struct OneCall: Decodable {
    let lat, lon: Double
    let timezone : String
    let timezone_offset : Int
    let current: CurrentResponse
    let hourly: HourlyResponse
    struct HourlyResponse: Decodable{
        let sunrise: Date?
        let sunset: Date?
        var hourly: Array<CurrentResponse>
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2025-02-13 10:21:58

它绝对不是text()中的数组。尚不清楚哪种类型的.hourly,但应该是类似的

Text("\(weather.hourly.hourly)")

It should definitely be not an array in Text(). It is not clear what's type of .hourly, but it should be something like

Text("\(weather.hourly.hourly)")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文