有没有办法用NSMutableArray做到这一点?
NSArray *myArray = @[@1, @2, @3];
或者,我必须这样做:
NSMutableArray *myArray = [NSMutableArray array];
[myArray addObject:@1];
[myArray addObject:@2];
[myArray addObject:@3];
或者:
NSArray *myArray = @[@1, @2, @3];
NSMutableArray *myMutableArray = [NSMutableArray arrayWithArray:myArray];
有没有单行方式来做到这一点?
答案 0 :(得分:2)
答案 1 :(得分:1)
尝试arrayWithArray
:
NSMutableArray* myArray = [NSMutableArray arrayWithArray:@[@1, @2, @3]];