RAHomeOrderModel.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // RAHomeOrderModel.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/1.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAHomeOrderModel.h"
  9. #import "UIImage+RedAnt.h"
  10. @implementation RAHomeOrderModel {
  11. UIImage *_icon;
  12. }
  13. - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
  14. }
  15. - (UIImage *)icon {
  16. return _icon;
  17. }
  18. - (void)setIcon:(UIImage *)icon {
  19. _icon = icon;
  20. if (self.delegate && [self.delegate respondsToSelector:@selector(refreshUI)]) {
  21. dispatch_async(dispatch_get_main_queue(), ^{
  22. [self.delegate refreshUI];
  23. });
  24. }
  25. }
  26. //- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
  27. // [super setValuesForKeysWithDictionary:keyedValues];
  28. //
  29. // [self setIconURL:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1536134884&di=9ea523019212b373ac04f4411e8aa56b&imgtype=jpg&er=1&src=http%3A%2F%2Fp3.music.126.net%2Fyp-UZgqWp6FV_AN4hPozjQ%3D%3D%2F109951163414711232.jpg"];
  30. //}
  31. - (void)setIconURL:(NSString *)iconURL {
  32. _iconURL = iconURL;
  33. if (_iconURL.length > 0 && [_iconURL hasPrefix:@"http"]) {
  34. __weak typeof(self) weakSelf = self;
  35. [RASingleton.sharedInstance.networkQueue addOperationWithBlock:^{
  36. UIImage *icon = [UIImage ra_imageWithURL:[NSURL URLWithString:iconURL]];
  37. if (weakSelf) {
  38. __strong typeof(weakSelf) strongSelf = weakSelf;
  39. [strongSelf setIcon:icon];
  40. }
  41. }];
  42. }
  43. }
  44. @end