OpenWeatherMap API每小时预测不可用
在我的天气应用程序中,我在文本字段中调用天气预报,但我会收到错误:在调用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它绝对不是
text()
中的数组。尚不清楚哪种类型的.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