Reputation: 17169
NSInteger *count = [monLessonArrayA count]; for (i = 0; i < count; i++) { arrayVar = [monLessonArrayA objectAtIndex:i]; }
I get an error saying i is undeclared, how can I set the objectAtIndex to i so I can loop through increasing it each time?
Thanks.
Upvotes: 3
Views: 7146
Reputation: 6878
You can also use fast enumeration, which is actually faster:
for (id someObject in monLessonArrayA) {
// Do stuff
}
Upvotes: 1
Reputation: 724572
You just forgot to declare i
(and its data type) before using it in the loop:
for (int i = 0; i < count; i++) {
Upvotes: 3
Reputation: 8775
Because your i is undeclared.
for (int i = 0; i < count; i++)
Also, you don't need the *
for your NSInteger
.
NSInteger count = [monLessonArrayA count];
Upvotes: 7