Gerriet Denkmann wrote:
While if fully agree with you about valid assumptions and so, I am still wondering what is the disadvantage of forgetting about NSEnumerator, Fast Enumeration and the like and simply doing:

unsigned count = [ array count ];
if ( count == 0 ) return;
for( unsigned i = count - 1;; i--)
{
        id a = [ array objectAtIndex: i ];
        if ( a is not nice ) [ array removeObjectAtIndex: i ];
        if ( i == 0 ) break;
}

That's a fine way of processing deletions from an array. You might prefer this C idiom to simplify the "loop backwards" code:

unsigned i = [ array count ];
while (i--) {
    id a = [ array objectAtIndex: i ];
    if ( a is not nice ) [ array removeObjectAtIndex: i ];
}


--
Greg Parker     [EMAIL PROTECTED]     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to