如何从Objective C中的对象列表中获取数据

时间:2012-12-10 05:18:27

标签: objective-c

我是Objective C的初学者。

我想知道如何使用for循环从对象列表[特定类的对象]中获取数据。

1 个答案:

答案 0 :(得分:1)

我会使用一个循环。以下是完成问题的示例代码

for(int itemIndex = 0;itemIndex < yourCollectionCount; itemIndex++){


    id myObject = yourCollection objectAtIndex:itemIndex]; //replace id  with your Collection Individual Item dataType

}

如果您知道项目的索引,请使用

id myObject = yourCollection objectAtIndex:knownIndex]; //replace id  with your Collection Individual Item dataType