Skip to content
This repository

Added loadImagesForURLs #15

Closed
wants to merge 2 commits into from

1 participant

Pierre-Olivier Marec
Pierre-Olivier Marec

Load asynchronously multiple images from their urls in one method with one callback.

Pierre-Olivier Marec

up

Pierre-Olivier Marec

Closed due to non-interest from community.

Pierre-Olivier Marec pomarec closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  EGOImageLoader/EGOImageLoader.h
@@ -61,6 +61,7 @@
61 61
 #if __EGOIL_USE_BLOCKS
62 62
 - (void)loadImageForURL:(NSURL*)aURL completion:(void (^)(UIImage* image, NSURL* imageURL, NSError* error))completion;
63 63
 - (void)loadImageForURL:(NSURL*)aURL style:(NSString*)style styler:(UIImage* (^)(UIImage* image))styler completion:(void (^)(UIImage* image, NSURL* imageURL, NSError* error))completion;
  64
+- (void)loadImagesForURLs:(NSSet*)someUrls completion:(void (^)(void))completion;
64 65
 #endif
65 66
 
66 67
 - (BOOL)hasLoadedImageURL:(NSURL*)aURL;
14  EGOImageLoader/EGOImageLoader.m
@@ -222,6 +222,20 @@ - (void)loadImageForURL:(NSURL*)aURL style:(NSString*)style styler:(UIImage* (^)
222 222
 		[completionCopy release];
223 223
 	}
224 224
 }
  225
+
  226
+- (void)loadImagesForURLs:(NSSet*)someUrls completion:(void (^)(void))completion {
  227
+    if (!someUrls || someUrls.count == 0)
  228
+        completion();
  229
+    else {        
  230
+        NSMutableSet *urlsToDownload = [NSMutableSet setWithSet:someUrls];
  231
+        for (NSURL *url in someUrls)
  232
+            [self loadImageForURL:url completion:^(UIImage *image, NSURL *imageURL, NSError *error) {
  233
+                [urlsToDownload removeObject:imageURL];
  234
+                if (urlsToDownload.count == 0)
  235
+                    completion();
  236
+            }];
  237
+    }
  238
+}
225 239
 #endif
226 240
 
227 241
 - (BOOL)hasLoadedImageURL:(NSURL*)aURL {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.