• 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: proper way to release a static NSMutableDictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proper way to release a static NSMutableDictionary?


  • Subject: Re: proper way to release a static NSMutableDictionary?
  • From: John Michael Zorko <email@hidden>
  • Date: Mon, 15 Dec 2008 15:27:16 -0800


Ashley,

Imagine this:

static NSMutableDictionary *lookup = [NSMutableDictionary new];

... now imagine a situation where I need to clear that dictionary. If I call

[lookup release];
lookup = [NSMutableDictionary new];

... it will obviously be faster than coding a for loop and removing each object in the dictionary, but since it was declared as static, which is safer?

As long as you are not retaining the objects referenced in the dictionary elsewhere, then when the dictionary is deallocated, all of its' referenced objects will be released. Whether the dictionary was declared static or not does not affect its' contents.

I'm not concerned about the contents per se -- i'm concerned about releasing something I declared as static, just to create it again later. Part of me is saying "just release the dictionary's contents, not the dictionary itself".


Regards,

John


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: proper way to release a static NSMutableDictionary?
      • From: Andy Lee <email@hidden>
    • Re: proper way to release a static NSMutableDictionary?
      • From: Graham Cox <email@hidden>
References: 
 >proper way to release a static NSMutableDictionary? (From: John Michael Zorko <email@hidden>)
 >Re: proper way to release a static NSMutableDictionary? (From: Ashley Clark <email@hidden>)

  • Prev by Date: Re: controlTextDidChange for UITextField?
  • Next by Date: Re: proper way to release a static NSMutableDictionary?
  • Previous by thread: Re: proper way to release a static NSMutableDictionary?
  • Next by thread: Re: proper way to release a static NSMutableDictionary?
  • Index(es):
    • Date
    • Thread