NSArray *aArr = @[@"hello", @"world"];
NSDictionary *aDic = @{@"h": @"hello", @"w":@"world"};
NSNumber *aNum = @15;
还是NSNumber类型的定义这样写:@15 也是xcode5的新特性?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
字面量方式声明在xcode 4.4就开始支持了(而实际是因为编译器支持,xcode 4.4将编译器升级为LLVM4.0了)。参考Apple的release note:
New Features in Xcode 4.4
使用总结参考:Objective-C literals for NSDictionary, NSArray, and NSNumber
另外还有数组和字典读写的语法糖