Objective-C 访问数组
我已经做了以下尝试创建 2d 和 3d 数组:
Array1 = [[NSMutableArray alloc]init];
Array2 = [[NSMutableArray alloc]init];
Array3 = [[NSMutableArray alloc]init];
for loop
[Array1 insertObject:Array2 atIndex:i];
//some code....
[Array2 insertObject:Array3 atIndex:j];
我不确定这是否正确,但每次我在代码中循环时,我都会将 Array2 添加到 Array1 中的新索引,但我注意到这是否有效。换句话说,我希望我不会每次都再次移动整个阵列?!!
现在我的问题是我需要通过 array1 循环访问 array2,然后通过 array2 访问 array3。我只需要知道如何使用循环访问这些数组,以便我可以显示每个数组的内容。我需要做类似数组 [i][j] 的事情 其中“i”代表数组 1,“j”代表数组 2
I have done the following trying to create 2d and 3d arrays:
Array1 = [[NSMutableArray alloc]init];
Array2 = [[NSMutableArray alloc]init];
Array3 = [[NSMutableArray alloc]init];
for loop
[Array1 insertObject:Array2 atIndex:i];
//some code....
[Array2 insertObject:Array3 atIndex:j];
im not sure if this is right but every time i loop in my code i add Array2 to a new index in Array1 but im note sure if this works. In other words i hope im not moving the whole array again every time ?!!
Now my problem is that i need to access array2 through looping in array1, then array3 through array2. I just need to know how to access these arrays using loops so that i can display each array's contents. I need to do something like this array [i][j]
where "i" for array1 and "j" is for array2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建 3d 阵列 (NxMxP):
使用此生物:
Create 3d-array (NxMxP):
Use this creature:
只写我所理解的...
for 访问循环中的数组
for循环
将给出
arr[i][j];
Just writing what I have understood...
for accessin the array in loop do
for loop
will give the the
arr[i][j];
我不确定我是否正确理解你,但如果你想访问数组中的数组,你可以使用
请完成这个SO问题如何在 iPhone 中创建数组的数组?
您需要这样的东西吗?
更新
I am not sure if i understand you properly but if you want to access an array within an array you can use
Pls go through this SO question How to create Array of Array in iPhone?
Is something like this what you need?
UPDATE