[swift-users] Printing Enums?

Alex Blewitt alblue at apple.com
Mon Jul 17 17:33:15 CDT 2017

> On 17 Jul 2017, at 15:15, Michael Rogers via swift-users <swift-users at 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 and use this example in case there's something that can be done to fix it.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170717/7a75d7b2/attachment.html>

More information about the swift-users mailing list