Objective-C enum in Swift

These get translated to

countDirection.Up
countDirection.Count

Swift removes as many letters as possible that the enum values have in common with the enumeration name. In your case, with an enumeration called countDirection and a value countDirectionUp, the whole "countDirection" is removed. It's not needed because you know which enum you are using, making your code considerable shorter.


With a bridging header and your enum values, I get the same error you do. However, if I change the enum values to:

typedef NS_ENUM(NSInteger, countDirection) {
    cdUp = 0,
    cdDown

};

...then I don't get any errors. For some reason, Swift does not like enum values that begin with the type name.

No error with these enum values either:

typedef NS_ENUM(NSInteger, countDirection) {
    CountDirectioUp = 0,
    CountDirectionDown
};