通过一个数组,它是另一个数组里面需要循环 [英] Need to loop through an array that is inside of another array
问题描述
我有一个包含两个对象的数组。为了将其存储在我的后端服务器的服务,我需要将其存储另一个数组里面。
I have an array that contains 2 objects. In order to store it on my backend server service, I need to store it inside of another array.
所以后来,当我打电话给我的服务器,并告诉它我想要的数组对象,它发送我,拿着我原来的数组对象一个新的数组对象。
So later on, when I call my server and tell it I want the array object, it sends me a new array object that is holding my original array object.
我需要循环通过新阵列(包含我原来的数组),然后遍历所有对象的我原来的数组中。
I need to loop through the new array (that contains my original array), and then loop through all of the objects inside of my original array.
我知道如何为循环和遍历数组做一个正常的,但我从未有过像这样做,你通过包含在另一个数组里的数组需要循环。
I know how to do a normal for loop and loop through an array, but I have never had to do it like this where you need to loop through an array that is contained inside of another array.
我一直在考虑如何约一个小时做到这一点,现在,真的没有任何线索。我想我需要做的是在技术上称为通过嵌套循环数组,但我似乎无法找到有关的Objective-C做这个事情。
I have been thinking about ways to do this now for about an hour and really have no clue. I think what I need to do is technically called "looping through nested arrays" but I can't seem to find anything about doing this with objective-c.
感谢您的帮助。
推荐答案
使用嵌套为
循环,可以通过物体在两个数组迭代:
Use a nested for
loop and you can iterate through the objects in both arrays:
for(NSArray* array in arrays){
for(object* thing in array){
//do what you want with thing in arrays
}
}
这篇关于通过一个数组,它是另一个数组里面需要循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!