• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: newbie question on 'Cocoa Programming for Mac OS X'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: newbie question on 'Cocoa Programming for Mac OS X'
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Overriding NSSlider/NSSliderCell: continued
  • Next by Date: RE: Multiple nibs
  • Previous by thread: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • Next by thread: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • Index(es):
    • Date
    • Thread