• 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: iterating and removing objects from a collection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iterating and removing objects from a collection


  • Subject: Re: iterating and removing objects from a collection
  • From: Sherm Pendley <email@hidden>
  • Date: Mon, 30 Nov 2009 16:37:13 -0500

On Mon, Nov 30, 2009 at 4:21 PM, Ken Thomases <email@hidden> wrote:
> On Nov 30, 2009, at 2:45 PM, Dennis Munsie wrote:
>
> Some alternatives:
>
> * Iterate over the array just using an index, rather than fast enumeration (or NSEnumerator).

A safe way to do that is to iterate backwards, starting at the max
index and counting down to 0. That way, removing the item at the
current index will only change the indexes of the items you've already
seen.

sherm--

--
Cocoa programming in Perl:
http://www.camelbones.org
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: iterating and removing objects from a collection
      • From: Jens Alfke <email@hidden>
References: 
 >iterating and removing objects from a collection (From: Dennis Munsie <email@hidden>)
 >Re: iterating and removing objects from a collection (From: Ken Thomases <email@hidden>)

  • Prev by Date: Re: Keyword @defs
  • Next by Date: Re: Keyword @defs
  • Previous by thread: Re: iterating and removing objects from a collection
  • Next by thread: Re: iterating and removing objects from a collection
  • Index(es):
    • Date
    • Thread