enum should support for custom ObjC name in @objc attribute
Originator: | pitiphong.ph | ||
Number: | rdar://22555701 | Date Originated: | 2015/09/03 |
Status: | Open | Resolved: | None |
Product: | Developer Tool | Product Version: | Xcode 7 beta 6 |
Classification: | Enhancement | Reproducible: | Not Applicable |
Summary: Now in Swift 2.0, you can provide custom name for Objective-C of Swift type but this feature isn’t allowed for Swift enum type. I think it would be great and make Swift and ObjC code looks nicer together example code/case: ```` @objc(PPTNotification) class Notification: NSObject { @objc(PPTNotificationAction) enum Action: Int { case Add case Delete case Edit } } let action = Notification.Action.Add // when use in Swift PPTNotificationAction action = PPTNotificationActionAdd; ```` From the above example code, it has an error ‘@objc enum cannot have a name’. Let’t think if this is allowed, from the example, the Swift code will looks like Swift, Objective-C code will looks like Objective-C and that would be great :) (Now I have to choose between declare enum at the outer scope ```` @objc enum PPTNotificationAction: Int { case Add case Delete case Edit } ```` or declare enum as a nested type but have a long name ```` @objc(PPTNotification) class Notification: NSObject { @objc enum PPTNotificationAction: Int { case Add case Delete case Edit } } ```` Both case make ObjC code looks fine but it make Swift code looks terrible. Xcode Version/Build & OS X Version/Build: Xcode 7 beta 6
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!