There’s already a radar filed for this (I don’t know if there’s a JIRA bug 
though).

The problem is that the standard library’s reflection mechanism only knows how 
to map the in-memory representation of an enum to a case name for native Swift 
enums. Objective-C enums are represented by their ‘raw value’, and we don’t 
store the mapping in a way that’s accessible to the reflection code.

Slava

> On Jul 17, 2017, at 3:33 PM, Alex Blewitt via swift-users 
> <swift-users@swift.org> wrote:
> 
>> On 17 Jul 2017, at 15:15, Michael Rogers via swift-users 
>> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
>> 
>> Hi, All:
>> 
>> Can someone please enlighten me as to why the first enum works as expected, 
>> giving me Melbourne, but the second gives UIModalPresentationStyle rather 
>> than fullScreen?
> 
> Sure - it's because it's an alias that is imported via Objective-C rather 
> than defined in Swift:
> 
> typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
>         UIModalPresentationFullScreen = 0,
>         UIModalPresentationPageSheet NS_ENUM_AVAILABLE_IOS(3_2) 
> __TVOS_PROHIBITED,
>         UIModalPresentationFormSheet NS_ENUM_AVAILABLE_IOS(3_2) 
> __TVOS_PROHIBITED,
>         UIModalPresentationCurrentContext NS_ENUM_AVAILABLE_IOS(3_2),
>         UIModalPresentationCustom NS_ENUM_AVAILABLE_IOS(7_0),
> 
> (you can see this in the UIViewController.h file in the UIKit, which is found 
> underneath your Xcode install)
> 
> The importer notes that the name of such typedef'd constants effectively 
> become translated into an enum as far as Swift source code is concerned, but 
> it's a different kind of case.
> 
> Having said that, it might be a bug in the case that the description of the 
> constant isn't the name of the element type. It would be worth raising this 
> on bugs.swift.org <http://bugs.swift.org/> and use this example in case 
> there's something that can be done to fix it.
> 
> Alex
> 
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to