NS_ENUM vs NS_OPTIONS

typedef NS_ENUM(NSUInteger, EnumState) {

State1,

State2,

State3,

};

typedef NS_OPTIONS(NSUInteger, EnumState) {

State1 = 1 << 0,

State2 = 1 << 1,

State3 = 1 << 2,

};

If you compile you code with Objective-C++, ORing the enumeration values of NS_OPTIONS causes error. So if you are going to OR enums, you use NS_OPTIONS.

Leave a comment