I know that I can override hash and isEqual
to check 2 instances equality. Xcode has the default snippet and doucument https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/ObjectComparison.html as following
- (BOOL)isEqual:(id)other
{
if (other == self) {
return YES;
} else if (![super isEqual:other]) { //WHAT is this line mean ?
return NO;
} else {
return <#comparison expression#>;
}
}
- (NSUInteger)hash
{
return <#hash expression#>;
}
Okay,
other == self
check two objects' pointers.if
![super isEqual:other]
, what is this line means ? If super object is not equal other, return NO ? Then it will always returnNO
, the step 3 will not be executed.
Am I wrong ?
Thanks.