The Apple guide for isEqual says:
Returns a Boolean value that indicates whether the receiver and a
given object are equal. (required)This method defines what it means for instances to be equal. For
example, a container object might define two containers as equal if
their corresponding objects all respond YES to anisEqual:request.
See the NSData, NSDictionary, NSArray, and NSString class
specifications for examples of the use of this method.If two objects are equal, they must have the same hash value. This
last point is particularly important if you defineisEqual: in a
subclass and intend to put instances of that subclass into a
collection. Make sure you also define hash in your subclass.
So my question is if I want to compare two UIButtons or two UILabels (two UIViews) using isEqual, and beforehand I have checked if their classes are the same class and then call isEqual, what is getting checked? are the properties, values, action messages, target objects are getting checked?
Thanks
the isEqual: method of NSObject checks whether the hash of the two objects are equal. In practice, the hash is the address of the instance if it isn’t overridden. However, on simple data container classes, isEqual is overridden, and, for example, the isEqual: method of NSString invokes isEqualToString: after checking that the object being compared to is an NSString instance. Same applies, as I’ve mentioned before, to NSData, NSNumber, NSDate, NSArray and NSDictionary. However, UIView (and all its parents) don’t override isEqual: as there’s no obvious way to decide whether two views are considered equal. You’d better compare another, more significant property of the views to be examined.