Typhoon and @objc limitation in protocols

坚强是说给别人听的谎言 提交于 2019-12-10 19:44:59

问题


Is there like an official workaround with protocols and types that are not supported in Object C

As an example, I have a protocol that returns a reactive cocoa signal producer

public protocol PLoginService {

      func login(username:String,password:String) -> SignalProducer<Bool,NSError>
}

If I use @objc on the protocol, then I will get the compiler error that the return type is not supported in Objective C. I will have a lot of constructions like this, so I was wondering what I can do in order to benefit from the Typhoon magic


回答1:


The current version of Typhoon is a reflective and dynamic dependency injection container, and therefore relies on the full Objective-C run-time. This means that, unfortunately, all protocols that will pass through Typhoon must have the @objc directive. Also, anything that Typhoon injects must be an Objective-C compatible type.

We're currently doing R&D on a pure Swift version of Typhoon, and you'd be most welcome to participate in the development of that project on Github.



来源:https://stackoverflow.com/questions/31661815/typhoon-and-objc-limitation-in-protocols

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!