PINRemoteImageManagerResult.m 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // PINRemoteImageManagerResult.m
  3. // Pods
  4. //
  5. // Created by Garrett Moon on 3/9/15.
  6. //
  7. //
  8. #import "PINRemoteImageManagerResult.h"
  9. @implementation PINRemoteImageManagerResult
  10. + (instancetype)imageResultWithImage:(PINImage *)image
  11. alternativeRepresentation:(id)alternativeRepresentation
  12. requestLength:(NSTimeInterval)requestLength
  13. error:(NSError *)error
  14. resultType:(PINRemoteImageResultType)resultType
  15. UUID:(NSUUID *)uuid
  16. {
  17. return [self imageResultWithImage:image
  18. alternativeRepresentation:alternativeRepresentation
  19. requestLength:requestLength
  20. error:error
  21. resultType:resultType
  22. UUID:uuid
  23. renderedImageQuality:1.0];
  24. }
  25. + (instancetype)imageResultWithImage:(PINImage *)image
  26. alternativeRepresentation:(id)alternativeRepresentation
  27. requestLength:(NSTimeInterval)requestLength
  28. error:(NSError *)error
  29. resultType:(PINRemoteImageResultType)resultType
  30. UUID:(NSUUID *)uuid
  31. renderedImageQuality:(CGFloat)renderedImageQuality
  32. {
  33. return [[self alloc] initWithImage:image
  34. alternativeRepresentation:alternativeRepresentation
  35. requestLength:requestLength
  36. error:error
  37. resultType:resultType
  38. UUID:uuid
  39. renderedImageQuality:renderedImageQuality];
  40. }
  41. - (instancetype)initWithImage:(PINImage *)image
  42. alternativeRepresentation:(id)alternativeRepresentation
  43. requestLength:(NSTimeInterval)requestLength
  44. error:(NSError *)error
  45. resultType:(PINRemoteImageResultType)resultType
  46. UUID:(NSUUID *)uuid
  47. renderedImageQuality:(CGFloat)renderedImageQuality
  48. {
  49. if (self = [super init]) {
  50. _image = image;
  51. _alternativeRepresentation = alternativeRepresentation;
  52. _requestDuration = requestLength;
  53. _error = error;
  54. _resultType = resultType;
  55. _UUID = uuid;
  56. _renderedImageQuality = renderedImageQuality;
  57. }
  58. return self;
  59. }
  60. - (NSString *)description
  61. {
  62. NSString *description = [super description];
  63. description = [description stringByAppendingString:[NSString stringWithFormat:@"image: %@", self.image]];
  64. description = [description stringByAppendingString:@"\n"];
  65. description = [description stringByAppendingString:[NSString stringWithFormat:@"alternativeRepresentation: %@", self.alternativeRepresentation]];
  66. description = [description stringByAppendingString:@"\n"];
  67. description = [description stringByAppendingString:[NSString stringWithFormat:@"requestDuration: %f", self.requestDuration]];
  68. description = [description stringByAppendingString:@"\n"];
  69. description = [description stringByAppendingString:[NSString stringWithFormat:@"error: %@", self.error]];
  70. description = [description stringByAppendingString:@"\n"];
  71. description = [description stringByAppendingString:[NSString stringWithFormat:@"resultType: %lu", (unsigned long)self.resultType]];
  72. description = [description stringByAppendingString:@"\n"];
  73. description = [description stringByAppendingString:[NSString stringWithFormat:@"UUID: %@", self.UUID]];
  74. description = [description stringByAppendingString:@"\n"];
  75. description = [description stringByAppendingString:[NSString stringWithFormat:@"renderedImageQuality: %f", self.renderedImageQuality]];
  76. return description;
  77. }
  78. @end