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];