Re: object instance names generated on the fly?
Re: object instance names generated on the fly?
- Subject: Re: object instance names generated on the fly?
- From: mmalcolm crawford <email@hidden>
- Date: Sat, 22 Mar 2003 22:40:05 -0800
On Saturday, March 22, 2003, at 08:51 AM, Dr. H. Nikolaus Schaller
wrote:
NSMutableDictionary *dict=[NSMutableDictionary
dictionaryWithCapacity:10];
to add a new instance of your object:
[dict setObject:[[yourClass alloc] init] forKey:yourKey];
[...]
Note that the NSMutableDictionary keeps care of all retains&releases.
Umm, not in your example it doesn't. You'd need either:
[dict setObject:[[[yourClass alloc] init] autorelease] forKey:yourKey];
or:
YourClass *yc = [[YourClass alloc] init];
[dict setObject:yc forKey:yourKey];
[yc release];
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.