Re: proper way to release a static NSMutableDictionary?
Re: proper way to release a static NSMutableDictionary?
- Subject: Re: proper way to release a static NSMutableDictionary?
- From: Ashley Clark <email@hidden>
- Date: Mon, 15 Dec 2008 17:18:05 -0600
On Dec 15, 2008, at 4:54 PM, John Michael Zorko wrote:
Hello, all ...
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 don't know of any reason to ever iterate over a dictionary removing
its' elements before you release it unless you are intending on saving
copies of those elements elsewhere.
Ashley
_______________________________________________
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