• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Weird behavior in NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Weird behavior in NSMutableDictionary
      • From: Clark Cox <email@hidden>
    • Re: Weird behavior in NSMutableDictionary
      • From: Thomas Lachand-Robert <email@hidden>
    • Re: Weird behavior in NSMutableDictionary
      • From: Steven Kramer <email@hidden>
  • Prev by Date: Getting app in the Force Quit List
  • Next by Date: Re: Getting app in the Force Quit List
  • Previous by thread: Re: Getting app in the Force Quit List
  • Next by thread: Re: Weird behavior in NSMutableDictionary
  • Index(es):
    • Date
    • Thread