• 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: NSMutableDictionary not sending release message to contained objects at dealloc time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSMutableDictionary not sending release message to contained objects at dealloc time
      • From: publiclook <email@hidden>
    • Re: NSMutableDictionary not sending release message to contained objects at dealloc time
      • From: mmalcolm crawford <email@hidden>
    • Re: NSMutableDictionary not sending release message to contained objects at dealloc time
      • From: Phill Kelley <email@hidden>
References: 
 >Re: NSMutableDictionary not sending release message to contained objects at dealloc time (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: NSProgressIndicator won't disappear!
  • Next by Date: Attaching data to image files
  • Previous by thread: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
  • Next by thread: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
  • Index(es):
    • Date
    • Thread