What on earth is the difference between these methods?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With