Skip to content

Commit 9f492cc

Browse files
niblhOlivier Poitrey
niblh
authored and
Olivier Poitrey
committed
Add userInfo on SDWebImageDownloader.m
1 parent 3f2f360 commit 9f492cc

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

SDWebImageDownloader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ extern NSString *const SDWebImageDownloadStopNotification;
1919
id<SDWebImageDownloaderDelegate> delegate;
2020
NSURLConnection *connection;
2121
NSMutableData *imageData;
22+
id userInfo;
2223
}
2324

2425
@property (nonatomic, retain) NSURL *url;
2526
@property (nonatomic, assign) id<SDWebImageDownloaderDelegate> delegate;
2627
@property (nonatomic, retain) NSMutableData *imageData;
28+
@property (nonatomic, retain) id userInfo;
2729

30+
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate userInfo:(id)userInfo;
2831
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate;
2932
- (void)start;
3033
- (void)cancel;

SDWebImageDownloader.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ @interface SDWebImageDownloader ()
1616
@end
1717

1818
@implementation SDWebImageDownloader
19-
@synthesize url, delegate, connection, imageData;
19+
@synthesize url, delegate, connection, imageData, userInfo;
2020

2121
#pragma mark Public Methods
2222

2323
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate
2424
{
25+
return [[self class] downloaderWithURL:url delegate:delegate userInfo:nil];
26+
}
27+
28+
+ (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)delegate userInfo:(id)userInfo
29+
{
30+
2531
// Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator )
2632
// To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import
2733
if (NSClassFromString(@"SDNetworkActivityIndicator"))
@@ -38,6 +44,7 @@ + (id)downloaderWithURL:(NSURL *)url delegate:(id<SDWebImageDownloaderDelegate>)
3844
SDWebImageDownloader *downloader = [[[SDWebImageDownloader alloc] init] autorelease];
3945
downloader.url = url;
4046
downloader.delegate = delegate;
47+
downloader.userInfo = userInfo;
4148
[downloader performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:YES];
4249
return downloader;
4350
}
@@ -129,6 +136,7 @@ - (void)dealloc
129136
[url release], url = nil;
130137
[connection release], connection = nil;
131138
[imageData release], imageData = nil;
139+
[userInfo release], userInfo = nil;
132140
[super dealloc];
133141
}
134142

SDWebImageDownloaderDelegate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* file that was distributed with this source code.
77
*/
88

9+
#import <UIKit/UIKit.h>
10+
911
@class SDWebImageDownloader;
1012

1113
@protocol SDWebImageDownloaderDelegate <NSObject>

0 commit comments

Comments
 (0)