これは私のisEqualとハッシュのカスタム演算子です
- (BOOL)isEqual:(id)object;
{
BGSearchParameter * theOther = (BGSearchParameter *)object;
BOOL isTheOtherEqual;
isTheOtherEqual = isTheOtherEqual && [self.Location isEqual:theOther.Location];
isTheOtherEqual = isTheOtherEqual && [self.keyword isEqual:theOther.keyword];
isTheOtherEqual = isTheOtherEqual && (self.Distance == theOther.Distance);
isTheOtherEqual = isTheOtherEqual && (self.SortByWhat == theOther.SortByWhat);
isTheOtherEqual = isTheOtherEqual && (self.startFrom == theOther.startFrom);
isTheOtherEqual = isTheOtherEqual && (self.numberOfIDstoGrab == theOther.numberOfIDstoGrab);
return isTheOtherEqual;
}
- (NSUInteger)hash
{
NSUInteger returnValue=0;
returnValue ^= self.Location.hash;
returnValue ^= self.keyword.hash;
return returnValue;
}
その人は仕事をします。ただし、距離と startfrom をハッシュに組み込みたいとします。
私は単に追加すると思います:
returnValue ^= self.Distance;
対応していないのでエラーです。
では、代わりに何をすべきですか?