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: Charles Steinman <email@hidden>
- Date: Mon, 15 Dec 2008 15:21:38 -0800 (PST)
----- Original Message ----
> From: John Michael Zorko <email@hidden>
> To: email@hidden
> Sent: Monday, December 15, 2008 2:54:46 PM
> Subject: proper way to release a static NSMutableDictionary?
>
>
> 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?
I don't see what being declared static has to do with it. As long as multiple threads don't touch the variable and nothing caches the value, both ways are equally safe. Otherwise, neither way is necessarily safe. Of course, if you want to clear the dictionary, it seems simplest just to do [lookup removeAllObjects].
Cheers,
Chuck
_______________________________________________
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