objective-c中这样定义数组和字典是xcode5中的新特性吗?
黄舟
黄舟 2017-04-21 11:18:18
0
2
646
    NSArray *aArr = @[@"hello", @"world"];
    NSDictionary *aDic = @{@"h": @"hello", @"w":@"world"};

    NSNumber *aNum = @15;

还是NSNumber类型的定义这样写:@15 也是xcode5的新特性?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
洪涛

Literal declaration has been supported since xcode 4.4 (actually because of compiler support, xcode 4.4 upgraded the compiler to LLVM4.0). Refer to Apple’s release note:

New Features in Xcode 4.4

Usage summary reference: Objective-C literals for NSDictionary, NSArray, and NSNumber

洪涛

Syntactic sugar, also translated as sugar-coated syntax, is a term invented by British computer scientist Peter J. Landin, which refers to a certain kind of syntax added to computer languages. This kind of sugar Syntax has no impact on the functionality of the language, but it is more convenient for programmers to use. Generally speaking, using syntax sugar can increase the readability of the program, thereby reducing the chance of program code errors.

In addition, there is syntax sugar for array and dictionary reading and writing

NSObject * obj = array[index];
NSObject * value = dict[key];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template