ITeye博客

IOS数组、字典新写法——@[]、@{}

lichangjielong · 2014-02-13 15:22 · 移动开发 · Objective-C · Markdown

苹果给objective-C一种新写法

比如 NSNumber * number = [NSNumber numberWithInt:1]; NSArray * array = [NSArray arrayWithObjects:@"one", @"two", nil]; NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:@"value1", @"key1", @"value2", @"key2", nil];

可以用 NSNumber * number = @1; NSArray * array = @[@"one", @"two"]; NSDictionary * dict = @{@"key1":@"value1", @"key2":@"value2"};

NSMutableArray *m_array = [@[] mutableCopy]; NSMutableDictionary *m_dict = [@{} mutableCopy];

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。