【发布时间】:2020-12-07 12:21:20
【问题描述】:
我正在用 Swift 编写 WeatherApp。我对称为“调用中的额外参数”的编译有问题。 我正在写 HourlyForecast,你可以在那里看到我的代码:
视图控制器:
HourlyForecast.downloadDailyForecastWeather { (hourlyForecastArray) in
for data in hourlyForecastArray {
print("forecast data: \(data.temp, data.date)")
}
}
HourlyForecast.swift 的一部分:
init(weatherDictionary: Dictionary<String, AnyObject>) {
let json = JSON(weatherDictionary)
self._temp = json["temp"].double
self._date = currentDateFromUnix(unixDate: json["ts"].double!)
self._weatherIcon = json["weather"]["icon"].stringValue
}
我该如何解决?
【问题讨论】:
-
你指的是什么方法调用?另一方面,我建议您查看
Codable协议