diff --git a/SDWebImageDownloader.h b/SDWebImageDownloader.h index aa2bafe..863a2e3 100644 --- a/SDWebImageDownloader.h +++ b/SDWebImageDownloader.h @@ -19,12 +19,15 @@ extern NSString *const SDWebImageDownloadStopNotification; id delegate; NSURLConnection *connection; NSMutableData *imageData; + id userInfo; } @property (nonatomic, retain) NSURL *url; @property (nonatomic, assign) id delegate; @property (nonatomic, retain) NSMutableData *imageData; +@property (nonatomic, retain) id userInfo; ++ (id)downloaderWithURL:(NSURL *)url delegate:(id)delegate userInfo:(id)userInfo; + (id)downloaderWithURL:(NSURL *)url delegate:(id)delegate; - (void)start; - (void)cancel; diff --git a/SDWebImageDownloader.m b/SDWebImageDownloader.m index 2004df7..bbae687 100644 --- a/SDWebImageDownloader.m +++ b/SDWebImageDownloader.m @@ -16,12 +16,18 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot @end @implementation SDWebImageDownloader -@synthesize url, delegate, connection, imageData; +@synthesize url, delegate, connection, imageData, userInfo; #pragma mark Public Methods + (id)downloaderWithURL:(NSURL *)url delegate:(id)delegate { + return [[self class] downloaderWithURL:url delegate:delegate userInfo:nil]; +} + ++ (id)downloaderWithURL:(NSURL *)url delegate:(id)delegate userInfo:(id)userInfo +{ + // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator ) // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import if (NSClassFromString(@"SDNetworkActivityIndicator")) @@ -38,6 +44,7 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot SDWebImageDownloader *downloader = [[[SDWebImageDownloader alloc] init] autorelease]; downloader.url = url; downloader.delegate = delegate; + downloader.userInfo = userInfo; [downloader performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:YES]; return downloader; } @@ -129,6 +136,7 @@ NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNot [url release], url = nil; [connection release], connection = nil; [imageData release], imageData = nil; + [userInfo release], userInfo = nil; [super dealloc]; } diff --git a/SDWebImageDownloaderDelegate.h b/SDWebImageDownloaderDelegate.h index 08939be..b710326 100644 --- a/SDWebImageDownloaderDelegate.h +++ b/SDWebImageDownloaderDelegate.h @@ -6,6 +6,8 @@ * file that was distributed with this source code. */ +#import + @class SDWebImageDownloader; @protocol SDWebImageDownloaderDelegate