Please read the question.
请阅读这个问题。
I know that we can't call Swift generic methods from Objective-C as per this link
我知道我们不能根据这个链接从Objective-C调用Swift通用方法
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
但我有一个项目是用Objective-C和Swift写的。有以Swift编写的网络库具有通用的GET、POST、DELETE方法。例如,下面是GET方法
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.
ResponseDeserializer是由少数其他类确认的协议。
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.
现在我的问题是是否有任何方法可以从Objective-C调用上述方法,或者我应该为Objective-C实现一个新的网络库。
I am looking for your valuable guidance.
我正在寻找您宝贵的指导。
1 个解决方案
#1
1
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.
不,即使它是一个图书馆,它仍然是用Swift写的。根据您提供的链接,您不能从Objective-C调用泛型方法,因为泛型是一个快速特性。
#1
1
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.
不,即使它是一个图书馆,它仍然是用Swift写的。根据您提供的链接,您不能从Objective-C调用泛型方法,因为泛型是一个快速特性。