不能在 Objective-C 中使用带有枚举的 Swift 类



我有一个 Swift 类,其中包含以下enum

    @objc public enum AlertStyle : Int {
    case Success,Error,Warning,None
    case CustomImag(imageFile:String)
}

我在 Objective-C 中使用 swift 类进行了桥接和其他集成阶段,但是当我构建应用程序时,编译器显示以下错误:

<unknown>:0: error: cannot assign value of type '(imageFile: String) -> AlertStyle' to type 'AlertStyle'

我该如何解决它?

具有

关联值的枚举不能在 Obj-C 中表示。如果你不需要你的枚举从objc-c可用,你可以删除@objc声明。在其他情况下,您需要重新设计解决方案。

遗憾的是,您不能在目标 C 中使用关联的值。

最新更新