Page 1 of 1

Removing objects in an NSArray one by one

Posted: Sat Jun 18, 2005 4:30 pm
by j10j
My NSArray has 10 entries,
and for an exercise I am told to remove the entries one by one, what is the fastest method?

for (i=9; i < 0 & i< 10; i--) {[array removeObjectAtIndex:i];}


while ([array count]>0){
[array removeLastObject];

PS: I am aware of removeAllObjects

Posted: Sat Jun 18, 2005 11:45 pm
by Nat!
The first piece of code is much much faster than the second one. :twisted: