Skip to content

Commit 42f9736

Browse files
author
Olivier Poitrey
committed
Merge pull request SDWebImage#607 from akhenakh/reformat_code
Code standardization
2 parents c00c2e0 + 03eeb58 commit 42f9736

21 files changed

+506
-834
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ key is an application unique identifier for the image to cache. It is generally
139139
the image.
140140
141141
```objective-c
142-
SDImageCache *imageCache = [SDImageCache.alloc initWithNamespace:@"myNamespace"];
142+
SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"];
143143
[imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image)
144144
{
145145
// image is not nil if image was found

SDWebImage/MKAnnotationView+WebCache.m

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,42 @@
1313

1414
@implementation MKAnnotationView (WebCache)
1515

16-
- (void)setImageWithURL:(NSURL *)url
17-
{
16+
- (void)setImageWithURL:(NSURL *)url {
1817
[self setImageWithURL:url placeholderImage:nil options:0 completed:nil];
1918
}
2019

21-
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
22-
{
20+
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder {
2321
[self setImageWithURL:url placeholderImage:placeholder options:0 completed:nil];
2422
}
2523

26-
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options
27-
{
24+
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options {
2825
[self setImageWithURL:url placeholderImage:placeholder options:options completed:nil];
2926
}
3027

31-
- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock
32-
{
28+
- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock {
3329
[self setImageWithURL:url placeholderImage:nil options:0 completed:completedBlock];
3430
}
3531

36-
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock
37-
{
32+
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock {
3833
[self setImageWithURL:url placeholderImage:placeholder options:0 completed:completedBlock];
3934
}
4035

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 {
4337
[self cancelCurrentImageLoad];
4438

4539
self.image = placeholder;
46-
47-
if (url)
48-
{
40+
41+
if (url) {
4942
__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) {
5244
if (!wself) return;
53-
dispatch_main_sync_safe(^
54-
{
45+
dispatch_main_sync_safe(^{
5546
__strong MKAnnotationView *sself = wself;
5647
if (!sself) return;
57-
if (image)
58-
{
48+
if (image) {
5949
sself.image = image;
6050
}
61-
if (completedBlock && finished)
62-
{
51+
if (completedBlock && finished) {
6352
completedBlock(image, error, cacheType);
6453
}
6554
});
@@ -68,12 +57,10 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder opt
6857
}
6958
}
7059

71-
- (void)cancelCurrentImageLoad
72-
{
60+
- (void)cancelCurrentImageLoad {
7361
// 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) {
7764
[operation cancel];
7865
objc_setAssociatedObject(self, &operationKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
7966
}

SDWebImage/SDImageCache.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@
99
#import <Foundation/Foundation.h>
1010
#import "SDWebImageCompat.h"
1111

12-
enum SDImageCacheType
13-
{
12+
typedef NS_ENUM(NSInteger, SDImageCacheType) {
1413
/**
1514
* The image wasn't available the SDWebImage caches, but was downloaded from the web.
1615
*/
17-
SDImageCacheTypeNone = 0,
16+
SDImageCacheTypeNone,
1817
/**
1918
* The image was obtained from the disk cache.
2019
*/
21-
SDImageCacheTypeDisk,
20+
SDImageCacheTypeDisk,
2221
/**
2322
* The image was obtained from the memory cache.
2423
*/
25-
SDImageCacheTypeMemory
24+
SDImageCacheTypeMemory
2625
};
27-
typedef enum SDImageCacheType SDImageCacheType;
2826

2927
/**
3028
* SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed

0 commit comments

Comments
 (0)