How to make a Swift String enum available in Objective-C?

前端 未结 10 2181
情深已故
情深已故 2020-12-01 07:09

I have this enum with String values, which will be used to tell an API method that logs to a server what kind of serverity a message has. I\'m using Swift 1.2,

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 07:47

    From the Xcode 6.3 release notes (emphasis added):

    Swift Language Enhancements

    ...
    Swift enums can now be exported to Objective-C using the @objc attribute. @objc enums must declare an integer raw type, and cannot be generic or use associated values. Because Objective-C enums are not namespaced, enum cases are imported into Objective-C as the concatenation of the enum name and case name.

提交回复
热议问题