Objective-C Mapping for Constants

Slice constant definitions map to corresponding Objective-C constant definitions. For example:

const bool      AppendByDefault = true;
const byte      LowerNibble = 0x0f;
const string    Advice = "Don't Panic!";
const short     TheAnswer = 42;
const double    PI = 3.1416;

enum Fruit { Apple, Pear, Orange }
const Fruit     FavoriteFruit = Pear;

Here are the generated definitions for these constants:

static const BOOL EXAppendByDefault = YES;
static const ICEByte EXLowerNibble = 15;
static NSString * const EXAdvice = @"Don't Panic!";
static const ICEShort EXTheAnswer = 42;
static const ICEDouble EXPI = 3.1416;

typedef enum
    EXApple, EXPear, EXOrange
} EXFruit;
static const EXFruit EXFavoriteFruit = EXPear;

All constants are initialized directly in the generated header file, so they are compile-time constants and can be used in contexts where a compile-time constant expression is required, such as to dimension an array or as the case label of a switch statement.

Slice string literals that contain non-ASCII characters or universal character names are mapped to Objective-C string literals with these characters replaced by their UTF-8 encoding as octal escapes. For example:

const string Egg = "œuf";
const string Heart = "c\u0153ur";
const string Banana = "\U0001F34C";

is mapped to:

static NSString * const demoEgg = @"\305\223uf";
static NSString * const demoHeart = @"c\305\223ur";
static NSString * const demoBanana = @"\360\237\215\214";

See Also