Re: NSMutableDictionary Memory Question
Re: NSMutableDictionary Memory Question
- Subject: Re: NSMutableDictionary Memory Question
- From: Mike Abdullah <email@hidden>
- Date: Fri, 23 Mar 2007 17:51:12 +0000
So my understanding is you have an arrangement something like this:
MyObject
NSMutableDictionary (instance variable called myDict)
NSMutableDictionary (as a dictionary key)
NSMutableDictionary (as a dictionary key)
where the objects higher up are retaining the ones below it. All you
should have to do is something like:
- (void)dealloc
{
[myDict release];
[super dealloc];
}
As you release myDict, it decreases its retain count. In all likely
hood, that is enough to deallocate it. As part of its deallocation,
the dictionary will release all keys and values, and they in turn may
well be deallocated.
You certainly do not need to enumerate through the objects releasing
them all; not unless you've screwed up the memory management
elsewhere anyway!
Mike.
On 23 Mar 2007, at 17:34, Matt wrote:
So I have a simple question that relates back to basic Cocoa memory
management. I have a dictionary with a few other dictionaries as
keys as well as a few nsnumbers. When deallocating my object that
contains this structure, I'm a bit confused on how to successfully
"kill" all retained objects. :)
If I have a mutabledictionary with other mutabledictionaries as
keys and send the top-level dic a -removeAllObjects method, and
therefore the lower-level dictionaries are giving a release
message, do those in turn pass that release message onto their
objects? I had looked at a loop with keyEnumerators (although you
can't modify the dictionary), iterating through an array of
returned keys, etc.
Any general advice is appreciated!
Matt
Mac Fanatic
http://www.macfanatic.net/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40mikeabdullah.net
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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