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
Showing
3 changed files
with
9 additions
and
9 deletions
@@ -57,7 +57,7 @@ typedef enum | @@ -57,7 +57,7 @@ typedef enum | ||
57 | extern NSString *const SDWebImageDownloadStartNotification; | 57 | extern NSString *const SDWebImageDownloadStartNotification; |
58 | extern NSString *const SDWebImageDownloadStopNotification; | 58 | extern NSString *const SDWebImageDownloadStopNotification; |
59 | 59 | ||
60 | -typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, NSUInteger expectedSize); | 60 | +typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); |
61 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); | 61 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); |
62 | 62 | ||
63 | /** | 63 | /** |
@@ -115,7 +115,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; | @@ -115,7 +115,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; | ||
115 | return _downloadQueue.maxConcurrentOperationCount; | 115 | return _downloadQueue.maxConcurrentOperationCount; |
116 | } | 116 | } |
117 | 117 | ||
118 | -- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock | 118 | +- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSInteger, NSInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock |
119 | { | 119 | { |
120 | __block SDWebImageDownloaderOperation *operation; | 120 | __block SDWebImageDownloaderOperation *operation; |
121 | __weak SDWebImageDownloader *wself = self; | 121 | __weak SDWebImageDownloader *wself = self; |
@@ -139,7 +139,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; | @@ -139,7 +139,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; | ||
139 | { | 139 | { |
140 | request.allHTTPHeaderFields = wself.HTTPHeaders; | 140 | request.allHTTPHeaderFields = wself.HTTPHeaders; |
141 | } | 141 | } |
142 | - operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSUInteger receivedSize, NSUInteger expectedSize) | 142 | + operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) |
143 | { | 143 | { |
144 | if (!wself) return; | 144 | if (!wself) return; |
145 | SDWebImageDownloader *sself = wself; | 145 | SDWebImageDownloader *sself = wself; |
@@ -183,7 +183,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; | @@ -183,7 +183,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; | ||
183 | return operation; | 183 | return operation; |
184 | } | 184 | } |
185 | 185 | ||
186 | -- (void)addProgressCallback:(void (^)(NSUInteger, NSUInteger))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback | 186 | +- (void)addProgressCallback:(void (^)(NSInteger, NSInteger))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback |
187 | { | 187 | { |
188 | // 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. | 188 | // 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. |
189 | if(url == nil) | 189 | if(url == nil) |
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | 19 | ||
20 | @property (assign, nonatomic, getter = isExecuting) BOOL executing; | 20 | @property (assign, nonatomic, getter = isExecuting) BOOL executing; |
21 | @property (assign, nonatomic, getter = isFinished) BOOL finished; | 21 | @property (assign, nonatomic, getter = isFinished) BOOL finished; |
22 | -@property (assign, nonatomic) NSUInteger expectedSize; | 22 | +@property (assign, nonatomic) NSInteger expectedSize; |
23 | @property (strong, nonatomic) NSMutableData *imageData; | 23 | @property (strong, nonatomic) NSMutableData *imageData; |
24 | @property (strong, nonatomic) NSURLConnection *connection; | 24 | @property (strong, nonatomic) NSURLConnection *connection; |
25 | @property (strong, atomic) NSThread *thread; | 25 | @property (strong, atomic) NSThread *thread; |
@@ -36,7 +36,7 @@ | @@ -36,7 +36,7 @@ | ||
36 | BOOL responseFromCached; | 36 | BOOL responseFromCached; |
37 | } | 37 | } |
38 | 38 | ||
39 | -- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock | 39 | +- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSInteger, NSInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock |
40 | { | 40 | { |
41 | if ((self = [super init])) | 41 | if ((self = [super init])) |
42 | { | 42 | { |
@@ -94,7 +94,7 @@ | @@ -94,7 +94,7 @@ | ||
94 | { | 94 | { |
95 | if (self.progressBlock) | 95 | if (self.progressBlock) |
96 | { | 96 | { |
97 | - self.progressBlock(0, -1); | 97 | + self.progressBlock(0, NSURLResponseUnknownLength); |
98 | } | 98 | } |
99 | [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; | 99 | [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; |
100 | 100 | ||
@@ -208,7 +208,7 @@ | @@ -208,7 +208,7 @@ | ||
208 | { | 208 | { |
209 | if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400) | 209 | if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400) |
210 | { | 210 | { |
211 | - NSUInteger expected = response.expectedContentLength > 0 ? (NSUInteger)response.expectedContentLength : 0; | 211 | + NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0; |
212 | self.expectedSize = expected; | 212 | self.expectedSize = expected; |
213 | if (self.progressBlock) | 213 | if (self.progressBlock) |
214 | { | 214 | { |
@@ -242,7 +242,7 @@ | @@ -242,7 +242,7 @@ | ||
242 | // Thanks to the author @Nyx0uf | 242 | // Thanks to the author @Nyx0uf |
243 | 243 | ||
244 | // Get the total bytes downloaded | 244 | // Get the total bytes downloaded |
245 | - const NSUInteger totalSize = self.imageData.length; | 245 | + const NSInteger totalSize = self.imageData.length; |
246 | 246 | ||
247 | // Update the data source, we must pass ALL the data, not just the new bytes | 247 | // Update the data source, we must pass ALL the data, not just the new bytes |
248 | CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL); | 248 | CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL); |
-
Please register or login to post a comment