Say I have an object called Person
which has the property socialSecurityNumber
, and this class overrides the isEqual:
method to return true when the social security number properties are equal. And say I've put a bunch of instances of Person
into an NSDictionary
.
If I now instantiate a newPerson
object which happens to have the same social security number as one already in the dictionary, and I do [myDictionary objectForKey:newPerson]
, will it use the isEqual:
and return YES, or will it compare pointers and return NO?
I know I can write a simple test to find out, but I want to understand how exactly objectForKey:
finds a match in a dictionary, and generally how consistent this is across Cocoa (i.e. does NSArray
's indexofObject:
work the same?)