Reputation: 4080
Please read the question.
I know that we can't call Swift generic methods from Objective-C as per this link
But in my case I have a project written in Objective-C and Swift. There is network library written in Swift having generic GET, POST, DELETE methods. For example below is GET method
public func get<T: ResponseDeserializer>(withDeserializer responseDeserializer: T, at relativePath: String? = nil, options: RestOptions = RestOptions(), callback: @escaping (APIResult<T.ResponseType>, HTTPURLResponse?) -> ()) {
makeCall(relativePath, httpMethod: RestAPIManager.kGetType, payload: nil, responseDeserializer: responseDeserializer, options: options, callback: callback)
}
Where ResponseDeserializer is a protocol confirmed by few other classes.
Now my question is that is there any way to call above methods from Objective-C or should I implement a new network library for Objective-C.
I am looking for your valuable guidance.
Upvotes: 3
Views: 794
Reputation: 9391
No, even though it is a library, it is still written in Swift. And per the link you provided, you cannot call generic methods from Objective-C, since generics are a Swift feature.
Upvotes: 1