RADetailPhotoModel.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // RADetailPhotoModel.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/9/4.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RADetailPhotoModel.h"
  9. #import "UIImage+RedAnt.h"
  10. @interface RADetailPhotoModel ()
  11. @end
  12. @implementation RADetailPhotoModel
  13. - (void)setPhotoURL:(NSString *)photoURL {
  14. _photoURL = photoURL;
  15. if (_photoURL.length > 0) {
  16. __weak typeof(self) weakSelf = self;
  17. [RASingleton.sharedInstance.networkQueue addOperationWithBlock:^{
  18. UIImage *photo = [UIImage ra_imageWithURL:[NSURL URLWithString:photoURL]];
  19. if (weakSelf) {
  20. __strong typeof(weakSelf) strongSelf = weakSelf;
  21. [strongSelf setPhoto:photo];
  22. }
  23. }];
  24. } else {
  25. [self setPhoto:nil];
  26. }
  27. }
  28. - (void)setPhoto:(UIImage *)photo {
  29. _photo = photo;
  30. if (self.delegate && [self.delegate respondsToSelector:@selector(refreshUI)]) {
  31. dispatch_async(dispatch_get_main_queue(), ^{
  32. [self.delegate refreshUI];
  33. });
  34. }
  35. }
  36. - (CGFloat)height {
  37. return 100.0f;
  38. }
  39. @end