简体   繁体   中英

can not use Swift class with enum in Objective-C

I have a Swift class that contains below enum :

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

I do the bridging and other integration phases for using swift classes in Objective-C, but when I build the app, compiler shows below error:

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

How can I fix it?

不幸的是,您不能在 Objective C 中使用关联值。

Enum with associated values can not be represented in Obj-C. If you don't need your enum to be available from objc-c you can remove @objc declaration. In other case you need to redesign your solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM