`
lichangjielong
  • 浏览: 21606 次
社区版块
存档分类
最新评论

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

阅读更多
苹果给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];
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics