ObjectMapper failed to serialize response
Closed this issue · 4 comments
Hi,
I'm trying to use AlamofireObjectMapper in a project with Switf 2 on Xcode 7.
I mapped an object into a class:
import Foundation
import ObjectMapper
class Item: Mappable {
var id: Int?
required init?(_ map: Map) {
}
func mapping(map: Map) {
id <- map["id"]
}
}
However, when I call it (as Github's example)
let URL = "xxx"
Alamofire.request(.GET, URL)
.responseObject("data") { (response: Response<Item, NSError>) in
print(response.result.value?.id)
print(response.result.error)
}
I got this error:
"Optional(Error Domain=com.alamofire.error Code=-6004 "ObjectMapper failed to serialize response." UserInfo={NSLocalizedFailureReason=ObjectMapper failed to serialize response.})"
This also happens with WeatherForecast example. What can be the problem?
i can't even compile, i get an error Value of type Request has no member 'responseObject'
Using swift 2.0 and xCode 7
I'm not sure why this is happening for you two... have you included the following line in your file?
import AlamofireObjectMapper
that did it. thanks.
i have the same issue "Value of type request has no member .responseObject",
import AlamofireObjectMapper is already added but issue is still exist.