Answer the question
In order to leave comments, you need to log in
How to make a function as a parameter to which to pass the class that is required to work inside the function?
class func getData(
Id: Int,
completion: @escaping (_ response: DataResponse<MapFeatureCard>) -> Void)
{
let urlPath = "https://site.ru/api/v11/superobjects/"+String(Id)
Alamofire.request(urlPath)
.validate()
.cache(maxAge: 60, isPrivate: false, ignoreServer: true)
.responseObject { (response: DataResponse<MapFeatureCard>) in
completion(response)
}
}
class func getData(
Id: Int,
RespType: Type = DataResponse<MapFeatureCard>,
completion: @escaping (_ response: RespType) -> Void)
{
let urlPath = "https://site.ru/api/v11/superobjects/"+String(Id)
Alamofire.request(urlPath)
.validate()
.cache(maxAge: 60, isPrivate: false, ignoreServer: true)
.responseObject { (response: RespType) in
completion(response)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question