Objective-C Mapping for Enumerations

A Slice enumeration maps to the corresponding enumeration in Objective-C. For example:

Slice
["objc:prefix:EX"]
module Example 
{
    enum Fruit { Apple, Orange, Pear }
}

The generated Objective-C definition is:

Objective-C
typedef enum 
{
    EXApple, EXOrange, EXPear
} EXFruit;

The metadata directive objc:scoped allows you to add the enumeration's name as prefix to all enumerators. For example:

Slice
["objc:prefix:EX"]
module Example 
{
    ["objc:scoped"] enum Fruit { Apple, Orange, Pear }
}

The generated Objective-C definition is:

Objective-C
typedef enum 
{
    EXFruitApple, EXFruitOrange, EXFruitPear
} EXFruit;

See Also