Re: NSMutableDictionary not sending release message to contained objects at dealloc time
Re: NSMutableDictionary not sending release message to contained objects at dealloc time
- Subject: Re: NSMutableDictionary not sending release message to contained objects at dealloc time
- From: mmalcolm crawford <email@hidden>
- Date: Fri, 11 Apr 2003 19:19:34 -0700
On Friday, April 11, 2003, at 04:02 PM, Greg Hurrell wrote:
Yet while array sends a release when objects are removed, the dict
only sends a release when it itself is deallocated (according to you,
and I defer to your experience on this one!)
Umm, no, it doesn't, and Greg didn't say that.
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableDictionary *md = [NSMutableDictionary dictionary];
RetainReporter *rr = [[RetainCounter alloc] init];\
NSLog(@"About to add rr to md");
[md setObject:rr forKey:@"rr"];
NSLog(@"About to release rr");
[rr release];
NSLog(@"About to remove rr from md");
[md removeObjectForKey:@"rr"];
NSLog(@"About to release pool");
[pool release];
About to add rr to md
retain
About to release rr
release
About to remove rr from md
release
dealloc
About to release pool
Please, sit back for a moment, and think about it a little more. Cocoa
memory management is usually *easier* than most people make it for
themselves...
<
http://www.stepwise.com/Articles/Technical/2001-03-11.01.html>
See in particular the last paragraph.
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.