我正在用字符串对象填充数组。可能有数千个。我在 for 循环中做了很多 alloc 和 inits,我知道这很昂贵。有什么更好、更有效的方法来做到这一点?
谢谢
//loop through the array of dictionaries
for(NSUInteger i =0; i < [latestResults count]; i++){
self.workingEntry = [[AppRecord alloc] init];
//Get the next dictionary from the array of dictionaries
NSDictionary *currentRecord = [latestResults objectAtIndex:i];
//Set the object
[self.workingEntry setAppURLString:[currentRecord valueForKeyPath:@"id.label"]];
[self.workingEntry setAppName:[currentRecord valueForKeyPath:@"im:name.label"]];
NSArray *imageArray = [currentRecord valueForKeyPath:@"im:image.label"];
[self.workingEntry setImageURLString:[imageArray objectAtIndex:0]];
[self.workingEntry setArtist:[currentRecord valueForKeyPath:@"im:artist.label"]];
//Add object to array
[self.workingArray addObject:self.workingEntry];
currentRecord = nil;
self.workingEntry = nil;
imageArray = nil;
}