第三条

多用字面量语法,少用与之等价的方法
字面量语法:

NSArray * tempAtt = @[@"1",@"2",@"3"];

对应等价的方法:

 NSArray * tempArray = [NSArray arrayWithObjects:@"1",@"2",@"3",nil];

获取方法:

 NSString * objectString = tempArray[1];

对应获取方法:

 NSString * objectString = [tempArray objectAtIndex:1];

注:此方法生产的对象都是不可变对象,可变对象需要

 NSMutableArray * tempArray = [@[@"1",@"2",@"3"] mutableCopy];

你可能感兴趣的:(第三条)