簡體   English   中英

不能在Objective-C中使用帶有枚舉的Swift類

[英]can not use Swift class with enum in Objective-C

我有一個包含以下enum的 Swift 類:

    @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'

我該如何解決?

不幸的是,您不能在 Objective C 中使用關聯值。

帶有關聯值的枚舉不能在 Obj-C 中表示。 如果你不需要你的枚舉從 objc-c 中可用,你可以刪除 @objc 聲明。 在其他情況下,您需要重新設計您的解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM