Dăn*_*ian 5 enums protocols ios swift
我在Swift中有这个枚举
enum Direction: Int{
case Left2Right = 0, Right2Left
}
Run Code Online (Sandbox Code Playgroud)
而这个协议
@objc protocol CellDelegate : NSObjectProtocol{
optional func has(direction:SwipeDirection) -> Bool
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误
Method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C
任何人都可以告诉我为什么会出现这个错误以及如何解决它?谢谢!
@objc属性使协议与Objective C兼容(即可用).但是在Objective C中没有swift enums(在1.2 beta之前).所以你不能在该协议中使用swift enum.
我认为最好的解决方案是使用swift 1.2 - 它仍处于测试版(截至今天),但可以将@objc属性应用于swift枚举.
| 归档时间: |
|
| 查看次数: |
1784 次 |
| 最近记录: |