• 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: NSEnumerator doesn't support NSCopying - why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSEnumerator doesn't support NSCopying - why?


  • Subject: Re: NSEnumerator doesn't support NSCopying - why?
  • From: Shawn Erickson <email@hidden>
  • Date: Wed, 11 Feb 2004 06:49:45 -0800

On Feb 10, 2004, at 2:09 AM, Wade Tregaskis wrote:

I'm trying to iterate through an array in the following way:

outerEnumerator = [objects objectEnumerator];

while (a = [outerEnumerator nextObject]) {
innerEnumerator = [outerEnumerator copy];

while (b = [innerEnumerator nextObject]) {
// do stuff here
}
}

Now, that'd be fantastic if NSEnumerator supported NSCopying. As is it raises an NSInvalidArgumentException (originating in copyWithZone:). I'm hesitant to revert to indexing into the array, since I would hope that using an enumerator would be faster.

Anyone know why an NSEnumerator (NSIdEnumerator, in this particular case) can't be copied, and some way to get around this, aside from the obvious i,j loop?

The double while loop construct above makes no sense to me... I guess you cut out the reason behind the double loop. I personally would use a single while loop (avoid scanning NxN[-1?]) and use continue to skip items and if/else logic for selective processing, etc.

Anyway what are you trying to do?

Why can't the inner while loop just use the same enumerator?

or

Why can't the inner while loop get its own enumerator by calling objectEnumerator?

You can file an enhancement request against NSEnumerator to get it to support copy (I assume not reseting the enumerator to beginning in the process).

-Shawn
_______________________________________________
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: NSEnumerator doesn't support NSCopying - why?
      • From: Wade Tregaskis <email@hidden>
References: 
 >NSEnumerator doesn't support NSCopying - why? (From: Wade Tregaskis <email@hidden>)

  • Prev by Date: [solved] Re: objc_msgSend in Codewarrior???
  • Next by Date: Re: objc_msgSend in Codewarrior???
  • Previous by thread: NSEnumerator doesn't support NSCopying - why?
  • Next by thread: Re: NSEnumerator doesn't support NSCopying - why?
  • Index(es):
    • Date
    • Thread