Re: NSMutableDictionary setObject:forKey:
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