BRResultModel.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // BRResultModel.m
  3. // BRPickerViewDemo
  4. //
  5. // Created by renbo on 2019/10/2.
  6. // Copyright © 2019 irenb. All rights reserved.
  7. //
  8. // 最新代码下载地址:https://github.com/91renb/BRPickerView
  9. #import "BRResultModel.h"
  10. @implementation BRResultModel
  11. /// 判断两个对象是否相等
  12. /// @param object 目标对象
  13. - (BOOL)isEqual:(id)object {
  14. // 1.对象的地址相同
  15. if (self == object) {
  16. return YES;
  17. }
  18. if (![object isKindOfClass:[BRResultModel class]]) {
  19. return NO;
  20. }
  21. BRResultModel *model = (BRResultModel *)object;
  22. if (!model) {
  23. return NO;
  24. }
  25. // 2.对象的类型相同,且对象的各个属性相等
  26. BOOL isSameKey = (!self.key && !model.key) || [self.key isEqualToString:model.key];
  27. BOOL isSameValue = (!self.value && !model.value) || [self.value isEqualToString:model.value];
  28. return isSameKey && isSameValue;
  29. }
  30. - (NSUInteger)hash {
  31. return [self.key hash] ^ [self.value hash];
  32. }
  33. - (NSString *)ID {
  34. return _key;
  35. }
  36. - (NSString *)name {
  37. return _value;
  38. }
  39. @end