I have a function
func mapResponse<T:Mappable>(responseObject:Alamofire.Request,
forRequest requestObject:RequestObject,
responseType:T,
completion:(AnyObject?,String?) -> Void)
{
responseObject.responseObject{(response: Response<T, NSError>) in
if let error = response.result.error {
completion(nil,error.description)
return
}
else {
let value:T = response.result.value!
self.saveObject(value, forRequest: requestObject,completion: completion)
}
}
}
when i call it like
let model:Mappable = requestObject.responseModel
ResponseMapper.sharedInstance.mapResponse(request,
forRequest:requestObject,
responseType:model,
completion:completion)
where
struct RequestObject {
let requestName:RequestName
let parametersStructure:Array<ParameterKey>?
let inputParameters:Dictionary<Parameter,AnyObject>?
let requestType:RequestType
let requestUrl:String
let cachLevel:CachLevel
let responseModel:Mappable
let parameterEncoding:ParameterEncoding
}
it give me error:
"Cannot invoke 'Method' with an argument list"
while it's working fine as following
ResponseMapper.sharedInstance.mapResponse(request,
forRequest:requestObject,
responseType:CarModel(),
completion:completion)
where
Class CarModel: Mappable
where is the problem with first call
requestObject.responseModel
should conform to Mappable
struct RequestObject<T where T:Mappable> {
let responseModel:T
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With