I use AlamofireObjectMapper extension. I want to get response, but it's failed. My tableLeague object is always nil because code with response closure doesn't call ({ (response: DataResponse) in if response.result.isSuccess { tableLeague = response.result.value } doesn't call). I use next methods:
let header = ["X-Auth-Token":"1231231"]
static let sharedInstance = ServerAPI()
private func getRequest(uri: String) -> DataRequest {
return Alamofire.request(uri, method: .get, headers: header)
}
public func getTableLeague() -> TableLeague {
var tableLeague: TableLeague?
getRequest(uri: URL).responseObject { (response: DataResponse<TableLeague>) in
if response.result.isSuccess {
tableLeague = response.result.value
}
}
return tableLeague!
}
And use in business class:
public func readTableLeague() -> TableLeague {
let tableLeague = ServerAPI.sharedInstance.getTableLeague()
return tableLeague
}
I think it can be because response haven't yet but i try to set object that i haven't yet
Whats a problem? Completion handlers i need to use else?
Please try to map by following structure
When you get JSON response simple map by this syntax