协议中的台风和@objc限制 [英] Typhoon and @objc limitation in protocols

查看:105
本文介绍了协议中的台风和@objc限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种官方的解决方法,可以解决对象C不支持的协议和类型

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>
}

如果我在协议上使用@objc,那么我将得到编译器错误,即目标C不支持返回类型.我将有很多这样的构造,所以我想知道我可以按顺序做什么从台风魔法中受益

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

推荐答案

Typhoon的当前版本是一个反射性和动态依赖项注入容器,因此依赖于完整的Objective-C运行时.不幸的是,这意味着将通过台风的所有协议都必须具有@objc指令.另外,台风注入的任何东西都必须是与Objective-C兼容的类型.

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.

我们目前正在使用纯Swift版本的Typhoon进行研发,非常欢迎您参与Github上该项目的开发.

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.

这篇关于协议中的台风和@objc限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆