LookinAttributesSection.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifdef SHOULD_COMPILE_LOOKIN_SERVER
  2. //
  3. // LookinAttributesSection.m
  4. // Lookin
  5. //
  6. // Created by Li Kai on 2019/3/2.
  7. // https://lookin.work
  8. //
  9. #import "LookinAttributesSection.h"
  10. #import "LookinAttribute.h"
  11. #import "NSArray+Lookin.h"
  12. @implementation LookinAttributesSection
  13. #pragma mark - <NSCopying>
  14. - (id)copyWithZone:(NSZone *)zone {
  15. LookinAttributesSection *newSection = [[LookinAttributesSection allocWithZone:zone] init];
  16. newSection.identifier = self.identifier;
  17. newSection.attributes = [self.attributes lookin_map:^id(NSUInteger idx, LookinAttribute *value) {
  18. return value.copy;
  19. }];
  20. return newSection;
  21. }
  22. #pragma mark - <NSCoding>
  23. - (void)encodeWithCoder:(NSCoder *)aCoder {
  24. [aCoder encodeObject:self.identifier forKey:@"identifier"];
  25. [aCoder encodeObject:self.attributes forKey:@"attributes"];
  26. }
  27. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  28. if (self = [super init]) {
  29. self.identifier = [aDecoder decodeObjectForKey:@"identifier"];
  30. self.attributes = [aDecoder decodeObjectForKey:@"attributes"];
  31. }
  32. return self;
  33. }
  34. + (BOOL)supportsSecureCoding {
  35. return YES;
  36. }
  37. @end
  38. #endif /* SHOULD_COMPILE_LOOKIN_SERVER */