RE: newbie question on 'Cocoa Programming for Mac OS X'
RE: newbie question on 'Cocoa Programming for Mac OS X'
- Subject: RE: newbie question on 'Cocoa Programming for Mac OS X'
- From: "Smith, Bradley" <email@hidden>
- Date: Mon, 11 Feb 2002 09:35:44 -0000
I did it (IIRC) by having an index offset that I incremented each time I
deleted an item.
e.g.
[employees removeObjectAtIndex:[anIndex intValue] - indexOffset++];
This keeps everything in synch nicely.
Brad
>
I solved the problem by reversing the order of the items in the
>
enumerator, so that you have a list of indices running from largest to
>
smallest, instead of smallest to largest. The re-indexing that
>
occurs upon deletion of an object from a mutable array only affects items
>
with higher indices than the one deleted, so you don't care about that if
>
you're deleting objects in reverse order of index. There's a very concise
>
way to reverse the order of the items in the enumerator:
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.