Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reformat a long method call

  • Loading branch information...
commit 03eeb5842f08514bf5ce50cea501f39fcde6c857 1 parent bdea43a
Fabrice Aneche akhenakh authored
Showing with 29 additions and 26 deletions.
  1. +29 −26 SDWebImage/SDWebImageDownloader.m
55 SDWebImage/SDWebImageDownloader.m
View
@@ -124,32 +124,35 @@ - (NSInteger)maxConcurrentDownloads {
else {
request.allHTTPHeaderFields = wself.HTTPHeaders;
}
- operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) {
- if (!wself) return;
- SDWebImageDownloader *sself = wself;
- NSArray *callbacksForURL = [sself callbacksForURL:url];
- for (NSDictionary *callbacks in callbacksForURL) {
- SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
- if (callback) callback(receivedSize, expectedSize);
- }
- }
- completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
- if (!wself) return;
- SDWebImageDownloader *sself = wself;
- NSArray *callbacksForURL = [sself callbacksForURL:url];
- if (finished) {
- [sself removeCallbacksForURL:url];
- }
- for (NSDictionary *callbacks in callbacksForURL) {
- SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
- if (callback) callback(image, data, error, finished);
- }
- }
- cancelled:^{
- if (!wself) return;
- SDWebImageDownloader *sself = wself;
- [sself removeCallbacksForURL:url];
- }];
+ operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request
+ options:options
+ progress:^(NSInteger receivedSize, NSInteger expectedSize) {
+ if (!wself) return;
+ SDWebImageDownloader *sself = wself;
+ NSArray *callbacksForURL = [sself callbacksForURL:url];
+ for (NSDictionary *callbacks in callbacksForURL) {
+ SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey];
+ if (callback) callback(receivedSize, expectedSize);
+ }
+ }
+ completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) {
+ if (!wself) return;
+ SDWebImageDownloader *sself = wself;
+ NSArray *callbacksForURL = [sself callbacksForURL:url];
+ if (finished) {
+ [sself removeCallbacksForURL:url];
+ }
+ for (NSDictionary *callbacks in callbacksForURL) {
+ SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey];
+ if (callback) callback(image, data, error, finished);
+ }
+ }
+ cancelled:^{
+ if (!wself) return;
+ SDWebImageDownloader *sself = wself;
+ [sself removeCallbacksForURL:url];
+ }];
+
[wself.downloadQueue addOperation:operation];
if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) {
// Emulate LIFO execution order by systematically adding new operations as last operation's dependency
Please sign in to comment.
Something went wrong with that request. Please try again.