LookinConnectionAttachment.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifdef SHOULD_COMPILE_LOOKIN_SERVER
  2. //
  3. // LookinConnectionAttachment.m
  4. // Lookin
  5. //
  6. // Created by Li Kai on 2019/2/15.
  7. // https://lookin.work
  8. //
  9. #import "LookinConnectionAttachment.h"
  10. #import "LookinDefines.h"
  11. #import "NSObject+Lookin.h"
  12. static NSString * const Key_Data = @"0";
  13. static NSString * const Key_DataType = @"1";
  14. @interface LookinConnectionAttachment ()
  15. @end
  16. @implementation LookinConnectionAttachment
  17. - (instancetype)init {
  18. if (self = [super init]) {
  19. }
  20. return self;
  21. }
  22. - (void)encodeWithCoder:(NSCoder *)aCoder {
  23. [aCoder encodeObject:[self.data lookin_encodedObjectWithType:self.dataType] forKey:Key_Data];
  24. [aCoder encodeInteger:self.dataType forKey:Key_DataType];
  25. }
  26. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  27. if (self = [super init]) {
  28. self.dataType = [aDecoder decodeIntegerForKey:Key_DataType];
  29. self.data = [[aDecoder decodeObjectForKey:Key_Data] lookin_decodedObjectWithType:self.dataType];
  30. }
  31. return self;
  32. }
  33. + (BOOL)supportsSecureCoding {
  34. return YES;
  35. }
  36. @end
  37. #endif /* SHOULD_COMPILE_LOOKIN_SERVER */