LookinAttributesGroup.m 1.5 KB

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