In article <160920031326401042%sgketchamcomcast.net>,
Steve Ketcham <sgketchamcomcast.net> wrote:
The docs for -[NSObject isEqual] note that:> I'd like to implement my own class for use as keys in an NSDictionary.
> My first try was to subclass NSObject and implement isEqual: and hash,
> which is what the NSDictionary doentation implies is necessary.
> When that didn't work, I subclassed NSString, but had problems
> initializing super with the text I wanted.
> Does anyone know what the requirements are, or where they might be
> (Or is this not possible? I note that the GNUstep doentation says
> that the key must be an NSString. Apple's doentation just says that
> the key is an object.)
"If two objects are equal, they must have the same hash value. This
last point is particularly important if you define isEqual: in a
subclass and intend to put instances of that subclass into a
collection. Make sure you also define hash in your subclass."
Did you implement -hash?
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 1.4: Best cleanup yet, gets files other tools miss.