13
13
14
14
@implementation MKAnnotationView (WebCache)
15
15
16
- - (void )setImageWithURL : (NSURL *)url
17
- {
16
+ - (void )setImageWithURL : (NSURL *)url {
18
17
[self setImageWithURL: url placeholderImage: nil options: 0 completed: nil ];
19
18
}
20
19
21
- - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder
22
- {
20
+ - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder {
23
21
[self setImageWithURL: url placeholderImage: placeholder options: 0 completed: nil ];
24
22
}
25
23
26
- - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder options : (SDWebImageOptions)options
27
- {
24
+ - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder options : (SDWebImageOptions)options {
28
25
[self setImageWithURL: url placeholderImage: placeholder options: options completed: nil ];
29
26
}
30
27
31
- - (void )setImageWithURL : (NSURL *)url completed : (SDWebImageCompletedBlock)completedBlock
32
- {
28
+ - (void )setImageWithURL : (NSURL *)url completed : (SDWebImageCompletedBlock)completedBlock {
33
29
[self setImageWithURL: url placeholderImage: nil options: 0 completed: completedBlock];
34
30
}
35
31
36
- - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder completed : (SDWebImageCompletedBlock)completedBlock
37
- {
32
+ - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder completed : (SDWebImageCompletedBlock)completedBlock {
38
33
[self setImageWithURL: url placeholderImage: placeholder options: 0 completed: completedBlock];
39
34
}
40
35
41
- - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder options : (SDWebImageOptions)options completed : (SDWebImageCompletedBlock)completedBlock
42
- {
36
+ - (void )setImageWithURL : (NSURL *)url placeholderImage : (UIImage *)placeholder options : (SDWebImageOptions)options completed : (SDWebImageCompletedBlock)completedBlock {
43
37
[self cancelCurrentImageLoad ];
44
38
45
39
self.image = placeholder;
46
-
47
- if (url)
48
- {
40
+
41
+ if (url) {
49
42
__weak MKAnnotationView *wself = self;
50
- id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL: url options: options progress: nil completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
51
- {
43
+ id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL: url options: options progress: nil completed: ^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) {
52
44
if (!wself) return ;
53
- dispatch_main_sync_safe (^
54
- {
45
+ dispatch_main_sync_safe (^{
55
46
__strong MKAnnotationView *sself = wself;
56
47
if (!sself) return ;
57
- if (image)
58
- {
48
+ if (image) {
59
49
sself.image = image;
60
50
}
61
- if (completedBlock && finished)
62
- {
51
+ if (completedBlock && finished) {
63
52
completedBlock (image, error, cacheType);
64
53
}
65
54
});
@@ -68,12 +57,10 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder opt
68
57
}
69
58
}
70
59
71
- - (void )cancelCurrentImageLoad
72
- {
60
+ - (void )cancelCurrentImageLoad {
73
61
// Cancel in progress downloader from queue
74
- id <SDWebImageOperation> operation = objc_getAssociatedObject (self, &operationKey);
75
- if (operation)
76
- {
62
+ id <SDWebImageOperation> operation = objc_getAssociatedObject (self, &operationKey);
63
+ if (operation) {
77
64
[operation cancel ];
78
65
objc_setAssociatedObject (self, &operationKey, nil , OBJC_ASSOCIATION_RETAIN_NONATOMIC );
79
66
}
0 commit comments