The NSDateFormatterStyle enum comes from Cocoa, so it is a C-style NS_ENUM enum and not a Swift enum.
In your EnumGenerator test you are hiding the original enum with your redeclaration, so your code only sees the redeclared Swift enum.
Using init(rawValue:) for NS_ENUM enums doesn't return nil for raw values which don't match any of the listed cases, so your EnumGenerator struct wouldn't work for an NS_ENUM either.
You can compare an NS_ENUM and a Swift enum in the playground (Xcode 7 beta 3, but same result in 6.4)
import Cocoa
let date = NSDate()
let formatter = NSDateFormatter()
var i: UInt = 0
while let style = NSDateFormatterStyle(rawValue: i) {
formatter.timeStyle = style
print("For style \(i) \(style.rawValue) Date/time = \(formatter.stringFromDate(date))")
++i
if (i > 100) {break}
}
enum SwiftDateStyle: UInt
{
case NoStyle
case ShortStyle
case MediumStyle
case LongStyle
case FullStyle
}
var j: UInt = 0
while let style = SwiftDateStyle(rawValue: j) {
formatter.timeStyle = NSDateFormatterStyle(rawValue: style.rawValue)!
print("For style \(j) \(style.rawValue) Date/time = \(formatter.stringFromDate(date))")
++j
if (j > 100) {break}
}
The NS_ENUM enum won't return nil from init(rawValue:) and will continue to run until stopped, but the Swift enum will return nil from init(rawValue:) and stop.