Weird behavior in NSMutableDictionary
Weird behavior in NSMutableDictionary
- Subject: Weird behavior in NSMutableDictionary
- From: Harilaos Skiadas <email@hidden>
- Date: Fri, 17 Dec 2004 20:10:29 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hey guys,
I just run into the following weird behavior, and
probably I am missing something very obvious, but I
just can't figure it out. I have an
NSMutableDictionary *aDict, and an NSDictionary
*anItem.
What I want to do is add anItem as an object to aDict,
with key the string that is the object corresponding
the key @"aKey" in anItem. I would have thought that
the following would work:
[aDict setValue:anItem forKey:[anItem
valueForKey:@"aKey"]];
instead, I had to use:
[aDict setValue:anItem forKey:[[anItem
valueForKey:@"aKey"] copy];
I thought that NSDictionary copies the keys when
adding items, so I don't quite see why I had to
provide the copy. Is this a bug? Is it documented? Has
anyone ever run into this?
Any thoughts on this would be much appreciated.
Haris
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden