LookinAttributesGroup.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifdef SHOULD_COMPILE_LOOKIN_SERVER
  2. //
  3. // LookinAttributesGroup.m
  4. // Lookin
  5. //
  6. // Created by Li Kai on 2018/11/19.
  7. // https://lookin.work
  8. //
  9. #import "LookinAttributesGroup.h"
  10. #import "LookinAttribute.h"
  11. #import "LookinAttributesSection.h"
  12. #import "NSArray+Lookin.h"
  13. @implementation LookinAttributesGroup
  14. #pragma mark - <NSCopying>
  15. - (id)copyWithZone:(NSZone *)zone {
  16. LookinAttributesGroup *newGroup = [[LookinAttributesGroup allocWithZone:zone] init];
  17. newGroup.identifier = self.identifier;
  18. newGroup.attrSections = [self.attrSections lookin_map:^id(NSUInteger idx, LookinAttributesSection *value) {
  19. return value.copy;
  20. }];
  21. return newGroup;
  22. }
  23. #pragma mark - <NSCoding>
  24. - (void)encodeWithCoder:(NSCoder *)aCoder {
  25. [aCoder encodeObject:self.identifier forKey:@"identifier"];
  26. [aCoder encodeObject:self.attrSections forKey:@"attrSections"];
  27. }
  28. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  29. if (self = [super init]) {
  30. self.identifier = [aDecoder decodeObjectForKey:@"identifier"];
  31. self.attrSections = [aDecoder decodeObjectForKey:@"attrSections"];
  32. }
  33. return self;
  34. }
  35. - (NSUInteger)hash {
  36. return self.identifier.hash;
  37. }
  38. - (BOOL)isEqual:(id)object {
  39. if (self == object) {
  40. return YES;
  41. }
  42. if (![object isKindOfClass:[LookinAttributesGroup class]]) {
  43. return NO;
  44. }
  45. if (self.identifier == ((LookinAttributesGroup *)object).identifier) {
  46. return YES;
  47. }
  48. return NO;
  49. }
  50. + (BOOL)supportsSecureCoding {
  51. return YES;
  52. }
  53. @end
  54. #endif /* SHOULD_COMPILE_LOOKIN_SERVER */