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: Randall Meadows <email@hidden>
- Date: Mon, 15 Dec 2008 16:17:42 -0700
On Dec 15, 2008, at 3: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.
[lookup removeAllObjects];
is probably your best choice.
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,
Maybe marginally; that release is going to cause a -release to be sent
to every object in the dictionary anyway, although Apple's
implementation is likely optimized.
My suggestion above prevents another object creation.
but since it was declared as static, which is safer?
I don't think safety matters either way, in this case.
_______________________________________________
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