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
- Slice Metadata Directives
- Objective-C Mapping for Modules
- Objective-C Mapping for Identifiers
- Objective-C Mapping for Built-In Types
- Objective-C Mapping for Structures
- Objective-C Mapping for Sequences
- Objective-C Mapping for Dictionaries
- Objective-C Mapping for Constants
- Objective-C Mapping for Exceptions
- Objective-C Mapping for Interfaces