isEqual: overridden without hash
ID |
objectivec.correctness.missing_hash |
Severity |
low |
Remediation Complexity |
medium |
Remediation Risk |
low |
Remediation Effort |
medium |
Resource |
Api Misuse |
Language |
Objective-C |
Description
This class overrides isEqual: but not hash. Two objects that compare equal must return the same hash, so without it the class misbehaves in NSSet and as an NSDictionary key. Override hash over the same fields isEqual: compares.
Rationale
This class overrides isEqual: but not hash. Two objects that compare equal must return the same hash, so without it the class misbehaves in NSSet and as an NSDictionary key. Override hash over the same fields isEqual: compares.
The following code illustrates the pattern detected by this rule:
// FLAGGED: isEqual: overridden without hash
@implementation NoHash
- (BOOL)isEqual:(id)other {
return YES;
}
@end