我正在遍历一个二维数组,如下所示:
for (menuViewController *aSelection in mainDataArray) {
...
}
但是,如何访问下层数组的数据呢? 下面的代码不起作用,但可以让您了解我的意思:
for (menuViewController *aSelection in mainDataArray) {
NSLog(@"Data: %@", [aSelection objectAtIndex:2]);
}
最佳答案
如果要遍历数组中的数组,可以尝试以下操作吗?
for (NSArray* aSelection in mainDataArray) {
NSLog(@"Data: %@", [aSelection objectAtIndex:2]);
}
关于objective-c - 遍历二维数组,使用for-in语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11386648/