我需要定义一个可以在使用某种Objective-c类型的类中调用的协议
但这样做不起作用:
enum NewsCellActionType: Int {
case Vote = 0
case Comments
case Time
}
@objc protocol NewsCellDelegate {
func newsCellDidSelectButton(cell: NewsCell, actionType: NewsCellActionType)
}
Run Code Online (Sandbox Code Playgroud)
你得到他的错误
Swift enums cannot be represented in Objective-C
Run Code Online (Sandbox Code Playgroud)
如果我没有将@objc标记放在我的协议上,那么只要在采用协议并从Objective-C类型类(如UIViewController)继承的类中调用它,它就会崩溃应用程序.
所以我的问题是,我应该如何使用@objc标签声明并传递我的枚举?