It is currently Mon Jul 15, 2024 10:15 pm

Mulle kybernetiK Optimization

Forum for Optimizations around Cocoa and Mac OS X

Removing objects in an NSArray one by one

Your code runs too slow. In need of a clue ? Ask your questions here.

Moderator: Nat!

Posts: 1
Joined: Sat Jun 18, 2005 4:21 pm

Removing objects in an NSArray one by one

Post by j10j » Sat Jun 18, 2005 4:30 pm

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

User avatar
Posts: 42
Joined: Fri Aug 06, 2004 9:20 am
Location: Bochum

Post by Nat! » Sat Jun 18, 2005 11:45 pm

The first piece of code is much much faster than the second one. :twisted:

Return to “Requests - Questions - Help”

Who is online

Users browsing this forum: No registered users and 1 guest