When we write
or
what is the type of .MediumStyle and .ShortStyle?
Trying
doesn’t work because the compiler thinks I’m trying to call .MediumStyle on whatever came before.
Is this a Swift feature? Where can I find more about how these are used in other contexts?
That is how Swift imports enumerations from Objective-C that have a common prefix.
Straight from the documentation for [b]NSDateFormatterStyle[/b]
:
The following constants specify predefined format styles for dates and times.
SWIFT
enum NSDateFormatterStyle : UInt {
case NoStyle
case ShortStyle
case MediumStyle
case LongStyle
case FullStyle
}
OBJECTIVE-C
typedef enum {
NSDateFormatterNoStyle = kCFDateFormatterNoStyle,
NSDateFormatterShortStyle = kCFDateFormatterShortStyle,
NSDateFormatterMediumStyle = kCFDateFormatterMediumStyle,
NSDateFormatterLongStyle = kCFDateFormatterLongStyle,
NSDateFormatterFullStyle = kCFDateFormatterFullStyle
} NSDateFormatterStyle;