二维数组 - 如何计算第二个数组?
2-Dimensions Array - how to count the 2nd array?
我正在 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++{
// …
}
根据你问题的上下文,我假设你不是指 "sum"(字符串的总和是多少?)而是数组的大小(有多少 strings/elements)
因为没有array_name.count像你想做的那样...
你想要:[array_name 计数]
如:NSLog(@"there are %d objects in the array", [array count])
我正在 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++{
// …
}
根据你问题的上下文,我假设你不是指 "sum"(字符串的总和是多少?)而是数组的大小(有多少 strings/elements)
因为没有array_name.count像你想做的那样...
你想要:[array_name 计数]
如:NSLog(@"there are %d objects in the array", [array count])