假设我有NSArray
60 个元素。其中,我想在索引 15、30、45、60 处获得 4 个值。我试图将其放入 for 循环中,但在这里效果不佳:
for (int elementIndex = x_valuesDataArray.count / 4; elementIndex < x_valuesDataArray.count; elementIndex = elementIndex + elementIndex){
NSLog(@"Element index is %d", elementIndex);
NSLog(@"Total values %u", x_valuesDataArray.count);
NSString *firstValue = [x_valuesDataArray objectAtIndex:elementIndex];
[xAxisArray02 addObject:firstValue];
}
但是我的NSLog
输出显示我做错了:
2013-04-12 13:48:59.267 myApp[44682:907] Element index is 15
2013-04-12 13:48:59.269 myApp[44682:907] Total values 60
2013-04-12 13:48:59.270 myApp[44682:907] Element index is 30
2013-04-12 13:48:59.271 myApp[44682:907] Total values 60
我在这里做错了什么?