Objective-C Language Defining an enum


Example

Enums are defined by the following the syntax above.

typedef NS_ENUM(NSUInteger, MyEnum) {
    MyEnumValueA,
    MyEnumValueB,
    MyEnumValueC,
};

You also can set your own raw-values to the enumeration types.

typedef NS_ENUM(NSUInteger, MyEnum) {
    MyEnumValueA = 0,
    MyEnumValueB = 5,
    MyEnumValueC = 10,
};

You can also specify on the first value and all the following will use it with increment:

typedef NS_ENUM(NSUInteger, MyEnum) {
    MyEnumValueA = 0,
    MyEnumValueB,
    MyEnumValueC,
};

Variables of this enum can be created by MyEnum enumVar = MyEnumValueA.