Re: NSMutableDictionary not sending release message to contained objects at dealloc time
Re: NSMutableDictionary not sending release message to contained objects at dealloc time
- Subject: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
- From: Greg Hurrell <email@hidden>
- Date: Sat, 12 Apr 2003 08:32:17 +0930
El Saturday, 12 Apr, 2003, a las 00:45 Australia/Adelaide, Greg Titus
escribis:
No, absolutely not. The contents of the dictionary should be sent a
release message when the dictionary itself is _dealloced_, to balance
the retain message they are sent when added to the dictionary. If you
retain the dictionary 10 times, it doesn't retain each object inside
the dictionary 10 times - those objects were retained _once_ when they
were added to the dictionary in the first place. If you then release
the dictionary 10 times, each object inside the dictionary is
unaffected. It is only when the dictionary itself is deallocated
(retain count goes to zero) that it is emptied and every object inside
it receives a single release.
Fair enough... My misunderstanding hinged on my belief that collection
classes like NSMutableDictionary and NSMutableArray would behave the
same.
Both send a retain as objects are added.
Yet while array sends a release when objects are removed, the dict only
sends a release when it itself is deallocated (according to you, and I
defer to your experience on this one!) Why the discrepancy in behaviour?
Cheers
Greg
_______________________________________________
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.