Substituting for-each for NSMutableArray

For all those who learn Objective C with GNUstep…

Mostly you will learn using For-Each statement , for manipulating NSMutableArray.
But with GNUstep, it is not possible.
The for each statement looks like this,
1 for(NSObject *st in myMutableArrayObject) {
2         NSLog(@"%@",[st myMethodDefined]);
3 }

Here is how we can do it without For-Each statement,
1 for(i=0; i< [myMutableArrayObject count]; i++) {
2     NSLog(@"%@",[[myMutableArrayObject objectAtIndex: i] myMethodDefined]);
3 }

Here, we are using a method predefined called count which returns the number of objects in the MutableArray Object
and then another method objectAtIndex which iterates the objects at the interval from 0 to (count – 1).

你可能感兴趣的:(table)