I have a model like this:
import UIKit
import ObjectMapper
struct Token: Mappable {
var token: String?
var deviceId: String?
init?(map: Map) {
}
mutating func mapping(map: Map) {
token <- map["token"]
deviceId <- map["device_id"]
}
}
So send a request with Alamofire like this:
import ObjectMapper
import Alamofire
override func viewDidLoad() {
super.viewDidLoad()
let request = ...
AF.request(request).validate(statusCode: 200..<300).responseJSON { (response:AFDataResponse<Any>) in
let token = Mapper<Token>().map(JSONString: serviceResponse.value) //Not work
}
}
When print my response that is correct but, I can't map it to my object model with ObjectMapper.
If you need return Value:
If you need return Array: