As you’ve correctly guessed, NSObject
‘s default isEqual:
behaviour is comparing the memory address of the object. Strangely, this is not presently documented in the NSObject Class Reference, but it is documented in the Introspection documentation, which states:
The default
NSObject
implementation ofisEqual:
simply checks for pointer equality.
Of course, as you are doubtless aware, subclasses of NSObject
can override isEqual:
to behave differently. For example, NSString
‘s isEqual:
method, when passed another NSString
, will first check the address and then check for an exact literal match between the strings.