RAHomeOrderModel.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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)setBackendFlag:(BOOL)backendFlag {
  19. _backendFlag = backendFlag;
  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)setIcon:(UIImage *)icon {
  27. _icon = icon;
  28. if (self.delegate && [self.delegate respondsToSelector:@selector(refreshUI)]) {
  29. dispatch_async(dispatch_get_main_queue(), ^{
  30. [self.delegate refreshUI];
  31. });
  32. }
  33. }
  34. //- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
  35. // [super setValuesForKeysWithDictionary:keyedValues];
  36. //
  37. // [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"];
  38. //}
  39. - (void)setIconURL:(NSString *)iconURL {
  40. _iconURL = iconURL;
  41. if (_iconURL.length > 0 && [_iconURL hasPrefix:@"http"]) {
  42. __weak typeof(self) weakSelf = self;
  43. [RASingleton.sharedInstance.networkQueue addOperationWithBlock:^{
  44. UIImage *icon = [UIImage ra_imageWithURL:[NSURL URLWithString:iconURL]];
  45. if (weakSelf) {
  46. __strong typeof(weakSelf) strongSelf = weakSelf;
  47. [strongSelf setIcon:icon];
  48. }
  49. }];
  50. }
  51. }
  52. @end