NSUnderlineStyle is an enum where one might expect an option set. In any case, you can see from the abbreviated definition below:
public enum NSUnderlineStyle : Int {
case StyleNone
case StyleSingle
case StyleThick
case StyleDouble
public static var PatternSolid: NSUnderlineStyle { get }
case PatternDot
case PatternDash
case PatternDashDot
case PatternDashDotDot
case ByWord
}What I need are two enum raw values or'd together. It so happened that I am using some functions (String-In-Chain) to build my attributed strings, so I tried something a bit odd to pass a single enum to my function:
let uStyle = NSUnderlineStyle(rawValue: NSUnderlineStyle.PatternDot.rawValue | NSUnderlineStyle.StyleSingle.rawValue)Amazingly, this worked, but now I'm scratching my head wondering why. Shouldn't I get a nil back? Does this mean Apple has added an extension to the enum to work the magic?
PS: In end end I dropped the above and added a new function to accept an array of enums.
Shouldn't I get a nil back? Does this mean Apple has added an extension to the enum to work the magic?
Maybe this is affecting:
Imported
NS_ENUM types with undocumented values, such as
UIViewAnimationCurve, can now be converted from their raw integer values using the
init(rawValue:) initializer without being reset to
nil. Code that used
unsafeBitCast as a workaround for this issue can be written to use the raw value initializer.