0
我最近已迁移到Swift
,所以请耐心和支持。 我使用Object Mapper
github page纠正语法的代码为Alamofire 4
ObjectMapper和Alamofire问题的斯威夫特Alamofire版本为Alamofire 4
let URL = "https://raw.githubusercontent.com/tristanhimmelman/AlamofireObjectMapper/d8bb95982be8a11a2308e779bb9a9707ebe42ede/sample_json"
Alamofire.request(URL).response { (response: DataResponse<WeatherResponse>) in
let weatherResponse = response.result.value
print(weatherResponse?.location)
if let threeDayForecast = weatherResponse?.threeDayForecast {
for forecast in threeDayForecast {
print(forecast.day)
print(forecast.temperature)
}
}
}
但我得到以下错误,如图截图。
感谢您帮助我获得正确的格式,但我需要完成响应建模请参考此链接https://github.com/tristanhimmelman/AlamofireObjectMapper –
然后您应该创建自己的完成处理程序方法,它返回数据你的格式,我猜 –
返回的是自动写入模型类 –