I wish to add 12 objects to a nsmutablearray, ready for the command InsertObject:atIndex:
There must be a quicker way than
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""开发者_运维知识库];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
[self.YoutubeArray addObject:@""];
for (NSInteger i = 0; i < 12; i++) { [self.YoutubeArray addObject:@""]; }
self.YoutubeArray = [NSMutableArray arrayWithObjects:@"",@"",...,@"",nil];
if you use static data
I'm guessing you don't actually NEED those empty strings, you're just setting up placeholders?
If so:
self.YoutubeArray = [NSMutableArray arrayWithCapacity:12];
Otherwise:
self.YoutubeArray = [NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"",
@"", @"", @"", @"", @"", @"", @"", nil];
NSMutableArray *arr = [NSMutableArray arrayWithObjects:@"" count:12];
精彩评论