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: "Michael Ash" <email@hidden>
- Date: Mon, 15 Dec 2008 22:45:27 -0500
On Mon, Dec 15, 2008 at 5:54 PM, John Michael Zorko <email@hidden> 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,
1) What makes it obvious?
2) Why do you care?
> but since it was declared as static, which is
> safer?
The static declaration is irrelevant. That just modifies where and how
the pointer gets stored. Memory management of the object itself is the
same as anything else. If you just want to empty out the dictionary,
[lookup removeAllObjects] seems like the nicest way to me, but use
whatever technique you like best.
Mike
_______________________________________________
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