NSInteger * count = [monLessonArrayA count];对于(i = 0; i < count; i ++){ arrayVar = [monLessonArrayA objectAtIndex:i]; }通过NSArray对象循环索引
我得到一个错误,说我是未申报的,我怎么能设置objectAtIndex我,所以我可以通过增加每次循环?
谢谢。
NSInteger * count = [monLessonArrayA count];对于(i = 0; i < count; i ++){ arrayVar = [monLessonArrayA objectAtIndex:i]; }通过NSArray对象循环索引
我得到一个错误,说我是未申报的,我怎么能设置objectAtIndex我,所以我可以通过增加每次循环?
谢谢。
因为你我没有申报。
for (int i = 0; i < count; i++)
而且,你不需要*
为您NSInteger
。
NSInteger count = [monLessonArrayA count];
你忘记了在循环使用它之前宣布i
(和它的数据类型):
for (int i = 0; i < count; i++) {
谢谢!傻我! – 2010-09-12 11:02:08
@Josh:加尔文还指出了你的“count”问题。 – BoltClock 2010-09-12 11:02:42
您还可以使用快速列举,这实际上要快:
for (id someObject in monLessonArrayA) {
// Do stuff
}
谢谢!傻我! – 2010-09-12 11:03:06