我正在寻找 xcode 中的代码来获取第二个数组的总和。您可以在代码中看到我的问题。如果有人能以这种方式支持我,我将不胜感激:
animation_images_buffer = [[NSMutableArray alloc] init];
NSArray *animationen_1 = @[@"image1_1.png", @" image1_2.png ", @" image1_3.png”];
NSArray *animationen_2 = @[@"image2_1.png", @" image2_2.png ", @" image2_3.png ", @" image2_4.png ", @" image2_5.png”];
[animation_images_buffer addObject:[UIImage imageNamed: animationen_1]];
[animation_images_buffer addObject:[UIImage imageNamed: animationen_2]];
// I would like to get the sum of animationen_2
for (int i = 0; i < animationen_2.count; i++) {
// …
}
// Is it possible to do it like this anyhow?
for (int i = 0; i < animation_images_buffer[2].count;i++{
// …
}
根据您问题的上下文,我假设您不是指"总和"(字符串的总和是多少?但是数组的大小(有多少个字符串/元素)
由于没有像您要做的array_name.count...
您需要:[array_name计数]
如:NSLog(@"数组中有 %d 个对象", [数组计数])