Difference between isEqualTo: and isEqual: Difference between isEqualTo: and isEqual: objective-c objective-c

Difference between isEqualTo: and isEqual:


isEqual: is part of the NSObject protocol and is meant for comparing objects.

isEqualTo: is part of the Cocoa AppleScript support infrastructure (specifically, NSComparisonMethods, which allow AppleScript to compare Cocoa objects). It's normally the same as isEqual:, but can be overridden if you want equality to work differently internally and in a script.


isEqualTo: is part of the NSComparisonMethods informal protocol, which also contains methods like isGreaterThan: and isNotEqualTo:, and is used for scripting support. And:

The default implementation for this method provided by NSObject returns YES if an isEqualTo: message sent to the same object would return YES.

So when sending this message to an NSObject (or any subclass which does not override it) you will get the same behavior as isEqual:, however, you should be using isEqual: instead.