Re: NSEnumerator retaining objects?
Re: NSEnumerator retaining objects?
- Subject: Re: NSEnumerator retaining objects?
- From: mmalcolm crawford <email@hidden>
- Date: Tue, 8 Mar 2005 22:12:26 -0800
On Mar 8, 2005, at 9:10 PM, James Bucanek wrote:
Enumerators do retain the collection that they're enumerating. This
is so that your app won't crash if something releases an array while
you're enumerating it.
That makes sense, but I was referring to NSEnuerator's propensity
to also retain/autorelease each individual object returned by
nextObject. This just seemed like overkill, given the fact the
objects are already retained by the collection.
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.
This clearly has implications for performance as well as memory
management...
I've filed a bug on this, although it's not clear to me whether it's
the documentation that's at fault or the implementation (the
documentation may be describing the intended behaviour).
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