Loop through NSArray objectAtIndex

NSInteger * count = [monLessonArrayA count]; for (i = 0; i <count; i ++) {arrayVar = [monLessonArrayA objectAtIndex: i]; }

I get an error: I am not declared, how can I set objectAtIndex to i so that I can loop it up every time?

Thank.

+3
source share
3 answers

Because your self is not declared.

for (int i = 0; i < count; i++)

In addition, you do not need *to NSInteger.

NSInteger count = [monLessonArrayA count]; 
+7
source

You just forgot to declare i(and its data type) before using it in a loop:

for (int i = 0; i < count; i++) {
+3
source

, :

for (id someObject in monLessonArrayA) {
    // Do stuff
}
+1

Source: https://habr.com/ru/post/1764361/


All Articles