Removing objects in an NSArray one by one

 
Post new topic   Reply to topic    Mulle kybernetiK Optimization Forum Index :: Requests - Questions - Help
View previous topic :: View next topic  
Author Message
j10j



Joined: 18 Jun 2005
Posts: 1

PostPosted: Sat Jun 18, 2005 4:30 pm    Post subject: Removing objects in an NSArray one by one Reply with quote

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];}

OR


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

PS: I am aware of removeAllObjects
Back to top
View user's profile Send private message
Nat!



Joined: 06 Aug 2004
Posts: 42
Location: Bochum

PostPosted: Sat Jun 18, 2005 11:45 pm    Post subject: Reply with quote

The first piece of code is much much faster than the second one. Twisted Evil
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Mulle kybernetiK Optimization Forum Index :: Requests - Questions - Help All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2002 phpBB Group
Charcoal2 Theme © Zarron Media