我正在寻找xcode中的代码来获取第二个数组的总和。 你在代码中看到了我的问题。如果anybode能以这种方式支持我,我将不胜感激:
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++{
// …
}
答案 0 :(得分:1)
根据你的问题的上下文,我假设你不是指“sum”(字符串的总和是多少?)但是数组的SIZE(有多少个字符串/元素)
因为没有像你想要的那样执行array_name.count ...
你想:[array_name count]
如:NSLog(@“数组中有%d个对象”,[数组计数])