Merge pull request #606 from akhenakh/64bits_support

use a NSInteger as size (was NSUInteger, was long long) cause we are using -1 (NSURLResponseUnknownLength) in progress callback
This commit is contained in:
Olivier Poitrey 2014-01-06 16:32:43 -08:00
commit c00c2e0ed4
3 changed files with 9 additions and 9 deletions

View File

@ -57,7 +57,7 @@ typedef enum
extern NSString *const SDWebImageDownloadStartNotification; extern NSString *const SDWebImageDownloadStartNotification;
extern NSString *const SDWebImageDownloadStopNotification; extern NSString *const SDWebImageDownloadStopNotification;
typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, NSUInteger expectedSize); typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);
/** /**

View File

@ -115,7 +115,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
return _downloadQueue.maxConcurrentOperationCount; return _downloadQueue.maxConcurrentOperationCount;
} }
- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock - (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSInteger, NSInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock
{ {
__block SDWebImageDownloaderOperation *operation; __block SDWebImageDownloaderOperation *operation;
__weak SDWebImageDownloader *wself = self; __weak SDWebImageDownloader *wself = self;
@ -139,7 +139,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
{ {
request.allHTTPHeaderFields = wself.HTTPHeaders; request.allHTTPHeaderFields = wself.HTTPHeaders;
} }
operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSUInteger receivedSize, NSUInteger expectedSize) operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize)
{ {
if (!wself) return; if (!wself) return;
SDWebImageDownloader *sself = wself; SDWebImageDownloader *sself = wself;
@ -183,7 +183,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
return operation; return operation;
} }
- (void)addProgressCallback:(void (^)(NSUInteger, NSUInteger))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback - (void)addProgressCallback:(void (^)(NSInteger, NSInteger))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
{ {
// The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data.
if(url == nil) if(url == nil)

View File

@ -19,7 +19,7 @@
@property (assign, nonatomic, getter = isExecuting) BOOL executing; @property (assign, nonatomic, getter = isExecuting) BOOL executing;
@property (assign, nonatomic, getter = isFinished) BOOL finished; @property (assign, nonatomic, getter = isFinished) BOOL finished;
@property (assign, nonatomic) NSUInteger expectedSize; @property (assign, nonatomic) NSInteger expectedSize;
@property (strong, nonatomic) NSMutableData *imageData; @property (strong, nonatomic) NSMutableData *imageData;
@property (strong, nonatomic) NSURLConnection *connection; @property (strong, nonatomic) NSURLConnection *connection;
@property (strong, atomic) NSThread *thread; @property (strong, atomic) NSThread *thread;
@ -36,7 +36,7 @@
BOOL responseFromCached; BOOL responseFromCached;
} }
- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock - (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSInteger, NSInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
@ -94,7 +94,7 @@
{ {
if (self.progressBlock) if (self.progressBlock)
{ {
self.progressBlock(0, -1); self.progressBlock(0, NSURLResponseUnknownLength);
} }
[[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self];
@ -208,7 +208,7 @@
{ {
if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400) if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400)
{ {
NSUInteger expected = response.expectedContentLength > 0 ? (NSUInteger)response.expectedContentLength : 0; NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0;
self.expectedSize = expected; self.expectedSize = expected;
if (self.progressBlock) if (self.progressBlock)
{ {
@ -242,7 +242,7 @@
// Thanks to the author @Nyx0uf // Thanks to the author @Nyx0uf
// Get the total bytes downloaded // Get the total bytes downloaded
const NSUInteger totalSize = self.imageData.length; const NSInteger totalSize = self.imageData.length;
// Update the data source, we must pass ALL the data, not just the new bytes // Update the data source, we must pass ALL the data, not just the new bytes
CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL); CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL);