第三条

作者: coder也爱诗 | 来源:发表于2019-04-14 10:21 被阅读0次

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

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

相关文章

网友评论

      本文标题:第三条

      本文链接:https://www.haomeiwen.com/subject/ypdjwqtx.html