1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
NSDictionary *dictionary = @{
@0: @"red", @1: @"green", @2: @"blue"
};
NSArray *array = @[@0, @1, @2, @YES, @'Z', @42U];
NSArray *multilineArray = @[
@0, @1, @2, @YES,
@'Z', @42U
];
void main(int argc, const char *argv[])
{
// character literals.
NSNumber *theLetterZ = @'Z'; // equivalent to [NSNumber numberWithChar:'Z']
// integral literals.
NSNumber *fortyTwo = @42; // equivalent to [NSNumber numberWithInt:42]
NSNumber *fortyTwoUnsigned = @42U; // equivalent to [NSNumber numberWithUnsignedInt:42U]
NSNumber *fortyTwoLong = @42L; // equivalent to [NSNumber numberWithLong:42L]
NSNumber *fortyTwoLongLong = @42LL; // equivalent to [NSNumber numberWithLongLong:42LL]
// floating point literals.
NSNumber *piFloat = @3.141592654F; // equivalent to [NSNumber numberWithFloat:3.141592654F]
NSNumber *piDouble = @3.1415926535; // equivalent to [NSNumber numberWithDouble:3.1415926535]
// BOOL literals.
NSNumber *yesNumber = @YES; // equivalent to [NSNumber numberWithBool:YES]
NSNumber *noNumber = @NO; // equivalent to [NSNumber numberWithBool:NO]
// Raw string literals
NSString *rawString = [NSString stringWithFormat:@R"(embedded " quotes " )"];
NSString *delimiterRawString = [NSString stringWithFormat:@R"<<<(embedded "quotes ')<<<"];
NSString *groupIDString = [NSString stringWithFormat:@R"({"group_id " : " % @",})", groupID];
NSString *config = @R"({"config_v1" : [
{"op1" : {"type":{"unsupported1":{}}},"markers":[123]},
{"op2" : {"type":{"jobs":{"suspend":true,"resume":false}}},"markers":[1]},
{"op3" : {"type":{"Good Format":{}}},"markers":[123]}
]})";
#ifdef __cplusplus
NSNumber *trueNumber = @true; // equivalent to [NSNumber numberWithBool:(BOOL)true]
NSNumber *falseNumber = @false; // equivalent to [NSNumber numberWithBool:(BOOL)false]
#endif
}
|