I have an Objective-C class that looks something like:
@interface myClass : NSObject
{
NSMutableDictionary *aDict;
}
Its setter method looks like:
- (void) setADict: (NSMutableDictionary *) newDict
{
[aDict release];
[newDict retain];
aDict = newDict;
}
I've created an instance of the object, put data into aDict, and now want to get rid of the object, cleaning up its memory in the process. Two questions:
1) Should I release aDict in myClass's dealloc method, as shown?
[aDict release];
=============================================================================
2) I've nested several children dictionaries into aDict, represented by keyA and keyB, like so:
// aDict:
{
keyA = {
keyA1 = "Hello world";
keyA2 = 1234;
};
keyB = {
keyB1 = Earth;
keyB2 = 25000;
};
}
Will a [aDict release] message "propagate down the chain" and cleanup all children dictionaries inside of aDict, including their key/value objects? Or, do I have to do something else to get rid of them?