Alamofire.request(todoEndpoint)
.responseJSON { response in
switch response.result {
case .success(let JSON):
let response: ETOOperatorsList = JSON as! ETOOperatorsList
delegate.requestWithReference(requestReference: "112", model: response as AnyObject)
case .failure(let error):
delegate.requestWithReference(requestReference: "112", error: error)
}
}
unable to cast giving an error
无法施放错误
"Could not cast a value of type '__NSDictionaryI' to 'OperatorsList'."
“无法将'__NSDictionaryI'类型的值强制转换为'OperatorsList'。”
How can I typecast Alamofire responseJSON
to a custom object?
如何将Alamofire responseJSON转换为自定义对象?
Thanks!
谢谢!
1 个解决方案
#1
0
There is no OJM (Object/Json Mapper) data binding functionality, to convert PONSOs to JSON vice versa, provided by Apple. Either you can do manual mapping or can use some third party one's. e.g.
Apple没有提供OJM(Object / Json Mapper)数据绑定功能,将PONSO转换为JSON,反之亦然。您可以进行手动映射,也可以使用某些第三方映射。例如
https://github.com/Hearst-DD/ObjectMapper https://github.com/tristanhimmelman/AlamofireObjectMapper
https://github.com/Hearst-DD/ObjectMapper https://github.com/tristanhimmelman/AlamofireObjectMapper
#1
0
There is no OJM (Object/Json Mapper) data binding functionality, to convert PONSOs to JSON vice versa, provided by Apple. Either you can do manual mapping or can use some third party one's. e.g.
Apple没有提供OJM(Object / Json Mapper)数据绑定功能,将PONSO转换为JSON,反之亦然。您可以进行手动映射,也可以使用某些第三方映射。例如
https://github.com/Hearst-DD/ObjectMapper https://github.com/tristanhimmelman/AlamofireObjectMapper
https://github.com/Hearst-DD/ObjectMapper https://github.com/tristanhimmelman/AlamofireObjectMapper