Skip to content

Commit c00c2e0

Browse files
author
Olivier Poitrey
committed
Merge pull request SDWebImage#606 from akhenakh/64bits_support
use a NSInteger as size (was NSUInteger, was long long) cause we are using -1 (NSURLResponseUnknownLength) in progress callback
2 parents 1e0af36 + 765a897 commit c00c2e0

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

SDWebImage/SDWebImageDownloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ typedef enum
5757
extern NSString *const SDWebImageDownloadStartNotification;
5858
extern NSString *const SDWebImageDownloadStopNotification;
5959

60-
typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, NSUInteger expectedSize);
60+
typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize);
6161
typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);
6262

6363
/**

SDWebImage/SDWebImageDownloader.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ - (NSInteger)maxConcurrentDownloads
115115
return _downloadQueue.maxConcurrentOperationCount;
116116
}
117117

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
119119
{
120120
__block SDWebImageDownloaderOperation *operation;
121121
__weak SDWebImageDownloader *wself = self;
@@ -139,7 +139,7 @@ - (NSInteger)maxConcurrentDownloads
139139
{
140140
request.allHTTPHeaderFields = wself.HTTPHeaders;
141141
}
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)
143143
{
144144
if (!wself) return;
145145
SDWebImageDownloader *sself = wself;
@@ -183,7 +183,7 @@ - (NSInteger)maxConcurrentDownloads
183183
return operation;
184184
}
185185

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
187187
{
188188
// 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.
189189
if(url == nil)

SDWebImage/SDWebImageDownloaderOperation.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ @interface SDWebImageDownloaderOperation ()
1919

2020
@property (assign, nonatomic, getter = isExecuting) BOOL executing;
2121
@property (assign, nonatomic, getter = isFinished) BOOL finished;
22-
@property (assign, nonatomic) NSUInteger expectedSize;
22+
@property (assign, nonatomic) NSInteger expectedSize;
2323
@property (strong, nonatomic) NSMutableData *imageData;
2424
@property (strong, nonatomic) NSURLConnection *connection;
2525
@property (strong, atomic) NSThread *thread;
@@ -36,7 +36,7 @@ @implementation SDWebImageDownloaderOperation
3636
BOOL responseFromCached;
3737
}
3838

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
4040
{
4141
if ((self = [super init]))
4242
{
@@ -94,7 +94,7 @@ - (void)start
9494
{
9595
if (self.progressBlock)
9696
{
97-
self.progressBlock(0, -1);
97+
self.progressBlock(0, NSURLResponseUnknownLength);
9898
}
9999
[[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self];
100100

@@ -208,7 +208,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespon
208208
{
209209
if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400)
210210
{
211-
NSUInteger expected = response.expectedContentLength > 0 ? (NSUInteger)response.expectedContentLength : 0;
211+
NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0;
212212
self.expectedSize = expected;
213213
if (self.progressBlock)
214214
{
@@ -242,7 +242,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
242242
// Thanks to the author @Nyx0uf
243243

244244
// Get the total bytes downloaded
245-
const NSUInteger totalSize = self.imageData.length;
245+
const NSInteger totalSize = self.imageData.length;
246246

247247
// Update the data source, we must pass ALL the data, not just the new bytes
248248
CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL);

0 commit comments

Comments
 (0)