Swiftui阵列带OpenWeatherMap
我在SwiftUI天气应用程序中进行了小时的预测,但是在我的结构中,它需要一个天气每小时数据的阵列。早些时候它符合字符串。我使其符合数组,但我得到了错误对通用类型“数组”的引用需要< ...>
中的参数。
struct:
struct OneCall: Decodable {
let lat, lon: Double
let timezone : String
let timezone_offset : Int
let current: CurrentResponse
let hourly: HourlyResponse
struct HourlyResponse: Decodable{
var hourly: Array //Error
}
}
我尝试使用<任何>
,但无效的
帮助将不胜感激
I have hourly forecast in my SwiftUI Weather App but in my struct, it needs an array for the weather hourly data. Earlier it was conformed to string. I made it conform to array but I get the error Reference to generic type 'Array' requires arguments in <...>
.
Struct:
struct OneCall: Decodable {
let lat, lon: Double
let timezone : String
let timezone_offset : Int
let current: CurrentResponse
let hourly: HourlyResponse
struct HourlyResponse: Decodable{
var hourly: Array //Error
}
}
I've tried using <Any>
but that didn't work
Help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
小时
的值实际上是currentResponse
struct MINUS MINUSSunrise
和Sunset
的数组。如果您使用这些使其可选
,并在 onecall 中声明
hourly
,或者对于错误消息而言,此语法
不需要
hourlylysponse
struct。任何
完全不支持Codable
。The value for
hourly
is actually an array of theCurrentResponse
struct minus the keyssunrise
andsunset
.If you use those make them optional
and declare
hourly
in OneCallor this syntax with regard to the error message
the
HourlyResponse
struct is not needed.Any
is not supported byCodable
at all.