VIContentInfo.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // VIContentInfo.m
  3. // VIMediaCacheDemo
  4. //
  5. // Created by Vito on 4/21/16.
  6. // Copyright © 2016 Vito. All rights reserved.
  7. //
  8. #import "VIContentInfo.h"
  9. static NSString *kContentLengthKey = @"kContentLengthKey";
  10. static NSString *kContentTypeKey = @"kContentTypeKey";
  11. static NSString *kByteRangeAccessSupported = @"kByteRangeAccessSupported";
  12. @implementation VIContentInfo
  13. - (NSString *)debugDescription {
  14. return [NSString stringWithFormat:@"%@\ncontentLength: %lld\ncontentType: %@\nbyteRangeAccessSupported:%@", NSStringFromClass([self class]), self.contentLength, self.contentType, @(self.byteRangeAccessSupported)];
  15. }
  16. - (void)encodeWithCoder:(NSCoder *)aCoder {
  17. [aCoder encodeObject:@(self.contentLength) forKey:kContentLengthKey];
  18. [aCoder encodeObject:self.contentType forKey:kContentTypeKey];
  19. [aCoder encodeObject:@(self.byteRangeAccessSupported) forKey:kByteRangeAccessSupported];
  20. }
  21. - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder {
  22. self = [super init];
  23. if (self) {
  24. _contentLength = [[aDecoder decodeObjectForKey:kContentLengthKey] longLongValue];
  25. _contentType = [aDecoder decodeObjectForKey:kContentTypeKey];
  26. _byteRangeAccessSupported = [[aDecoder decodeObjectForKey:kByteRangeAccessSupported] boolValue];
  27. }
  28. return self;
  29. }
  30. @end