• 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
Re: NSMutableDictionary setObject:forKey:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary setObject:forKey:


  • Subject: Re: NSMutableDictionary setObject:forKey:
  • From: Andy Lee <email@hidden>
  • Date: Sat, 11 Jun 2005 19:32:45 -0400

On Jun 11, 2005, at 7:05 PM, Theodore H. Smith wrote:
setObject:forKey: What kind of objects can the keys be?

Anything for which -isEqual: (and, by implication, -hash) and the NSCopying protocol are properly implemented. See the "Class Description" section of the docs for NSDictionary.


The docs say this: "- (id)objectForKey:(id)aKey. Returns an entry’s value given its key, or nil if no value is associated with aKey."

OK. But I tested this with [NSObject alloc]init] as the key, and it didn't work.

What does "I tested this" mean? What does "it didn't work" mean?

Also, I tested this with two different NSMutableStrings (which I made sure did not point to the same data, because I created them piece by piece), where the strings were the same data, and the dictionary only contained one key/value.

Isn't that the proper behavior if you used the two equal strings as keys? If you can use -isEqual: to compare the strings, and the result is YES, that means the strings are the same key for purposes of NSDictionary.


--Andy

_______________________________________________
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


References: 
 >NSMutableDictionary setObject:forKey: (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Re: NSMutableDictionary setObject:forKey:
  • Next by Date: Re: NSMutableDictionary setObject:forKey:
  • Previous by thread: Re: NSMutableDictionary setObject:forKey:
  • Next by thread: Re: NSMutableDictionary setObject:forKey:
  • Index(es):
    • Date
    • Thread