Skip to content

Commit 03eeb58

Browse files
committed
reformat a long method call
1 parent bdea43a commit 03eeb58

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

SDWebImage/SDWebImageDownloader.m

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,35 @@ - (NSInteger)maxConcurrentDownloads {
124124
else {
125125
request.allHTTPHeaderFields = wself.HTTPHeaders;
126126
}
127-
operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) {
128-
if (!wself) return;
129-
SDWebImageDownloader *sself = wself;
130-
NSArray *callbacksForURL = [sself callbacksForURL:url];
131-
for (NSDictionary *callbacks in callbacksForURL) {
132-
SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
133-
if (callback) callback(receivedSize, expectedSize);
134-
}
135-
}
136-
completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
137-
if (!wself) return;
138-
SDWebImageDownloader *sself = wself;
139-
NSArray *callbacksForURL = [sself callbacksForURL:url];
140-
if (finished) {
141-
[sself removeCallbacksForURL:url];
142-
}
143-
for (NSDictionary *callbacks in callbacksForURL) {
144-
SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
145-
if (callback) callback(image, data, error, finished);
146-
}
147-
}
148-
cancelled:^{
149-
if (!wself) return;
150-
SDWebImageDownloader *sself = wself;
151-
[sself removeCallbacksForURL:url];
152-
}];
127+
operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request
128+
options:options
129+
progress:^(NSInteger receivedSize, NSInteger expectedSize) {
130+
if (!wself) return;
131+
SDWebImageDownloader *sself = wself;
132+
NSArray *callbacksForURL = [sself callbacksForURL:url];
133+
for (NSDictionary *callbacks in callbacksForURL) {
134+
SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
135+
if (callback) callback(receivedSize, expectedSize);
136+
}
137+
}
138+
completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
139+
if (!wself) return;
140+
SDWebImageDownloader *sself = wself;
141+
NSArray *callbacksForURL = [sself callbacksForURL:url];
142+
if (finished) {
143+
[sself removeCallbacksForURL:url];
144+
}
145+
for (NSDictionary *callbacks in callbacksForURL) {
146+
SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
147+
if (callback) callback(image, data, error, finished);
148+
}
149+
}
150+
cancelled:^{
151+
if (!wself) return;
152+
SDWebImageDownloader *sself = wself;
153+
[sself removeCallbacksForURL:url];
154+
}];
155+
153156
[wself.downloadQueue addOperation:operation];
154157
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {
155158
// Emulate LIFO execution order by systematically adding new operations as last operation's dependency

0 commit comments

Comments
 (0)