VICacheAction.m 908 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // VICacheAction.m
  3. // VIMediaCacheDemo
  4. //
  5. // Created by Vito on 4/21/16.
  6. // Copyright © 2016 Vito. All rights reserved.
  7. //
  8. #import "VICacheAction.h"
  9. @implementation VICacheAction
  10. - (instancetype)initWithActionType:(VICacheAtionType)actionType range:(NSRange)range {
  11. self = [super init];
  12. if (self) {
  13. _actionType = actionType;
  14. _range = range;
  15. }
  16. return self;
  17. }
  18. - (BOOL)isEqual:(VICacheAction *)object {
  19. if (!NSEqualRanges(object.range, self.range)) {
  20. return NO;
  21. }
  22. if (object.actionType != self.actionType) {
  23. return NO;
  24. }
  25. return YES;
  26. }
  27. - (NSUInteger)hash {
  28. return [[NSString stringWithFormat:@"%@%@", NSStringFromRange(self.range), @(self.actionType)] hash];
  29. }
  30. - (NSString *)description {
  31. return [NSString stringWithFormat:@"actionType %@, range: %@", @(self.actionType), NSStringFromRange(self.range)];
  32. }
  33. @end