• 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: copy versus arrayWithArray:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy versus arrayWithArray:


  • Subject: Re: copy versus arrayWithArray:
  • From: Chris Suter <email@hidden>
  • Date: Mon, 21 Aug 2006 10:03:59 +1000


On 18/08/2006, at 10:35 PM, Eric Scharff wrote:

--- Chris Suter <email@hidden> wrote:

Why not iterate through the items using an index? Then you
don't need
to make a copy.

That's probably the best solution, but my actual code is more complicated than my simple example. I have one object that iterates over the collection, calling methods on the contents. Many subsequent method calls deep, something might call the original (iterating) object to add or remove things. I should be able to do this by making i and count member variables of the iterating object, but then I think I may have to worry about other synchronization concerns.

Assuming you only ever add to the end and that you only ever remove the object that the iterator points to, you can record what the last object is in the array and use that instead of count and at the end of every iteration, you can check to see if the object at the current index is what it was at the beginning of the iteration.


- Chris

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: copy versus arrayWithArray: (From: Eric Scharff <email@hidden>)

  • Prev by Date: Core Data Fetch Request Template
  • Next by Date: Sub NSToolbar???
  • Previous by thread: Re: copy versus arrayWithArray:
  • Next by thread: Re: copy versus arrayWithArray:
  • Index(es):
    • Date
    • Thread