Re: NSEnumerator retaining objects?
Re: NSEnumerator retaining objects?
- Subject: Re: NSEnumerator retaining objects?
- From: mmalcolm crawford <email@hidden>
- Date: Wed, 9 Mar 2005 11:04:52 -0800
On Mar 9, 2005, at 8:12 AM, James Bucanek wrote:
Marco Scheurer wrote on Wednesday, March 9, 2005:
I checked with the version of frameworks I'm using, and sad but true,
objects are retained by nextObject!
Thanks for the confirmation. Can you also easily confirm if the
NSEnumerator retains the collection?
I already posted this -- no, it doesn't:
Actually empirical investigation suggests that the documentation is
at odds with the implementation.
As far as I can tell, an NSEnumerator does not retain the
collection per se. -nextObject does, however, retain and
autorelease the object returned.
But, as has already been pointed out, you should never remove an
object from an array while iterating through it. And if you plan
to do something with an object that you're going to remove from a
collection, you should retain it first. So the above code is
already suspect and deserves to break, IMNSHO.
Unless anyone else can present a counter example, I think I'll file
a bug on this too.
Again as noted earlier, I've already filed a bug on this and I will
ensure that all aspects are addressed. This is one occasion when
multiple reports won't add value.
mmalc
_______________________________________________
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