字面量语法:
NSNumber* intNum =@5;
NSNumber* floatNum =@1.4f;
NSNumber* boolNum =@YES;
NSArray* array =@[@"dog",@"cat"];
NSString* dog = array[0];
id object1 = /* … */;
id object2 = /* … */;
id object3 = /* … */;
NSArray * arrayA = [NSArray arrayWithObjects:object1,object2,object3,nil];
NSArray * arrayB = @[object1,object2,object3];
字面量语法创建字典,键在值得前面
NSDictionary* dic =@{@"firstName":@"王",@"lastName":@"小哥"};
NSString * lastName = dic[@“lastName”];
网友评论