Skip to content

Commit 853ad83

Browse files
author
Olivier Poitrey
committed
Merge pull request SDWebImage#603 from akhenakh/64bits_support
64bits support (fix SDWebImage#572, fix SDWebImage#504, fix SDWebImage#494)
2 parents 8f8228e + 77fad5c commit 853ad83

File tree

7 files changed

+35
-21
lines changed

7 files changed

+35
-21
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ It provides:
1616
- A guarantee that main thread will never be blocked
1717
- Performances!
1818
- Use GCD and ARC
19+
- Arm64 support
1920

20-
NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.0
21+
NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1
2122
minimum deployement version. If you need iOS < 5.0 support, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat).
2223

2324
[How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F)

SDWebImage.xcodeproj/project.pbxproj

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@
835835
531041DE157EAFA400BBABC3 /* Debug */ = {
836836
isa = XCBuildConfiguration;
837837
buildSettings = {
838+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
838839
CLANG_ENABLE_OBJC_ARC = YES;
839840
COPY_PHASE_STRIP = NO;
840841
DEAD_CODE_STRIPPING = NO;
@@ -848,6 +849,7 @@
848849
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
849850
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
850851
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
852+
ONLY_ACTIVE_ARCH = NO;
851853
OTHER_LDFLAGS = "-ObjC";
852854
PRODUCT_NAME = "SDWebImage+MKAnnotation";
853855
SKIP_INSTALL = YES;
@@ -858,6 +860,7 @@
858860
531041DF157EAFA400BBABC3 /* Release */ = {
859861
isa = XCBuildConfiguration;
860862
buildSettings = {
863+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
861864
CLANG_ENABLE_OBJC_ARC = YES;
862865
COPY_PHASE_STRIP = NO;
863866
DEAD_CODE_STRIPPING = NO;
@@ -881,6 +884,7 @@
881884
53761323155AD0D5005750A4 /* Debug */ = {
882885
isa = XCBuildConfiguration;
883886
buildSettings = {
887+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
884888
CLANG_ENABLE_OBJC_ARC = YES;
885889
COPY_PHASE_STRIP = NO;
886890
DEAD_CODE_STRIPPING = NO;
@@ -904,6 +908,7 @@
904908
53761324155AD0D5005750A4 /* Release */ = {
905909
isa = XCBuildConfiguration;
906910
buildSettings = {
911+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
907912
CLANG_ENABLE_OBJC_ARC = YES;
908913
COPY_PHASE_STRIP = NO;
909914
DEAD_CODE_STRIPPING = NO;
@@ -927,6 +932,7 @@
927932
537D95BF17ECC1FE0097C263 /* Debug */ = {
928933
isa = XCBuildConfiguration;
929934
buildSettings = {
935+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
930936
CLANG_ENABLE_OBJC_ARC = YES;
931937
COPY_PHASE_STRIP = NO;
932938
DEAD_CODE_STRIPPING = NO;
@@ -954,6 +960,7 @@
954960
537D95C017ECC1FE0097C263 /* Release */ = {
955961
isa = XCBuildConfiguration;
956962
buildSettings = {
963+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
957964
CLANG_ENABLE_OBJC_ARC = YES;
958965
COPY_PHASE_STRIP = NO;
959966
DEAD_CODE_STRIPPING = NO;
@@ -978,6 +985,7 @@
978985
isa = XCBuildConfiguration;
979986
buildSettings = {
980987
ALWAYS_SEARCH_USER_PATHS = NO;
988+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
981989
COPY_PHASE_STRIP = NO;
982990
GCC_DYNAMIC_NO_PIC = NO;
983991
GCC_OPTIMIZATION_LEVEL = 0;
@@ -1001,7 +1009,7 @@
10011009
GCC_WARN_UNUSED_PARAMETER = NO;
10021010
GCC_WARN_UNUSED_VARIABLE = YES;
10031011
HEADER_SEARCH_PATHS = Vendors/libwebp/src;
1004-
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
1012+
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
10051013
PUBLIC_HEADERS_FOLDER_PATH = include/SDWebImage;
10061014
RUN_CLANG_STATIC_ANALYZER = YES;
10071015
SDKROOT = iphoneos;
@@ -1012,6 +1020,7 @@
10121020
isa = XCBuildConfiguration;
10131021
buildSettings = {
10141022
ALWAYS_SEARCH_USER_PATHS = NO;
1023+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
10151024
COPY_PHASE_STRIP = YES;
10161025
GCC_PREPROCESSOR_DEFINITIONS = "";
10171026
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@@ -1029,7 +1038,7 @@
10291038
GCC_WARN_UNUSED_PARAMETER = NO;
10301039
GCC_WARN_UNUSED_VARIABLE = YES;
10311040
HEADER_SEARCH_PATHS = Vendors/libwebp/src;
1032-
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
1041+
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
10331042
PUBLIC_HEADERS_FOLDER_PATH = include/SDWebImage;
10341043
RUN_CLANG_STATIC_ANALYZER = YES;
10351044
SDKROOT = iphoneos;
@@ -1040,13 +1049,17 @@
10401049
539F912D16316D2D00160719 /* Debug */ = {
10411050
isa = XCBuildConfiguration;
10421051
buildSettings = {
1052+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
1053+
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
10431054
PRODUCT_NAME = "$(TARGET_NAME)";
10441055
};
10451056
name = Debug;
10461057
};
10471058
539F912E16316D2D00160719 /* Release */ = {
10481059
isa = XCBuildConfiguration;
10491060
buildSettings = {
1061+
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
1062+
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
10501063
PRODUCT_NAME = "$(TARGET_NAME)";
10511064
};
10521065
name = Release;

SDWebImage/SDImageCache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ typedef enum SDImageCacheType SDImageCacheType;
4545
/**
4646
* The maximum size of the cache, in bytes.
4747
*/
48-
@property (assign, nonatomic) unsigned long long maxCacheSize;
48+
@property (assign, nonatomic) NSUInteger maxCacheSize;
4949

5050
/**
5151
* Returns global shared cache instance
@@ -153,7 +153,7 @@ typedef enum SDImageCacheType SDImageCacheType;
153153
/**
154154
* Get the size used by the disk cache
155155
*/
156-
- (unsigned long long)getSize;
156+
- (NSUInteger)getSize;
157157

158158
/**
159159
* Get the number of images in the disk cache
@@ -163,7 +163,7 @@ typedef enum SDImageCacheType SDImageCacheType;
163163
/**
164164
* Asynchronously calculate the disk cache's size.
165165
*/
166-
- (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, unsigned long long totalSize))completionBlock;
166+
- (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, NSUInteger totalSize))completionBlock;
167167

168168
/**
169169
* Check if image exists in cache already

SDWebImage/SDImageCache.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ - (void)cleanDisk
423423

424424
NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-self.maxCacheAge];
425425
NSMutableDictionary *cacheFiles = [NSMutableDictionary dictionary];
426-
unsigned long long currentCacheSize = 0;
426+
NSUInteger currentCacheSize = 0;
427427

428428
// Enumerate all of the files in the cache directory. This loop has two purposes:
429429
//
@@ -449,7 +449,7 @@ - (void)cleanDisk
449449

450450
// Store a reference to this file and account for its total size.
451451
NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey];
452-
currentCacheSize += [totalAllocatedSize unsignedLongLongValue];
452+
currentCacheSize += [totalAllocatedSize unsignedIntegerValue];
453453
[cacheFiles setObject:resourceValues forKey:fileURL];
454454
}
455455

@@ -458,7 +458,7 @@ - (void)cleanDisk
458458
if (self.maxCacheSize > 0 && currentCacheSize > self.maxCacheSize)
459459
{
460460
// Target half of our maximum cache size for this cleanup pass.
461-
const unsigned long long desiredCacheSize = self.maxCacheSize / 2;
461+
const NSUInteger desiredCacheSize = self.maxCacheSize / 2;
462462

463463
// Sort the remaining cache files by their last modification time (oldest first).
464464
NSArray *sortedFiles = [cacheFiles keysSortedByValueWithOptions:NSSortConcurrent
@@ -474,7 +474,7 @@ - (void)cleanDisk
474474
{
475475
NSDictionary *resourceValues = cacheFiles[fileURL];
476476
NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey];
477-
currentCacheSize -= [totalAllocatedSize unsignedLongLongValue];
477+
currentCacheSize -= [totalAllocatedSize unsignedIntegerValue];
478478

479479
if (currentCacheSize < desiredCacheSize)
480480
{
@@ -508,9 +508,9 @@ - (void)backgroundCleanDisk
508508
});
509509
}
510510

511-
- (unsigned long long)getSize
511+
- (NSUInteger)getSize
512512
{
513-
unsigned long long size = 0;
513+
NSUInteger size = 0;
514514
NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:self.diskCachePath];
515515
for (NSString *fileName in fileEnumerator)
516516
{
@@ -533,14 +533,14 @@ - (int)getDiskCount
533533
return count;
534534
}
535535

536-
- (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, unsigned long long totalSize))completionBlock
536+
- (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, NSUInteger totalSize))completionBlock
537537
{
538538
NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES];
539539

540540
dispatch_async(self.ioQueue, ^
541541
{
542542
NSUInteger fileCount = 0;
543-
unsigned long long totalSize = 0;
543+
NSUInteger totalSize = 0;
544544

545545
NSFileManager *fileManager = [NSFileManager defaultManager];
546546
NSDirectoryEnumerator *fileEnumerator = [fileManager enumeratorAtURL:diskCacheURL
@@ -552,7 +552,7 @@ - (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, unsigne
552552
{
553553
NSNumber *fileSize;
554554
[fileURL getResourceValue:&fileSize forKey:NSURLFileSizeKey error:NULL];
555-
totalSize += [fileSize unsignedLongLongValue];
555+
totalSize += [fileSize unsignedIntegerValue];
556556
fileCount += 1;
557557
}
558558

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, long long expectedSize);
60+
typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, NSUInteger 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, long long))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock
118+
- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))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, long long expectedSize)
142+
operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSUInteger receivedSize, NSUInteger 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, long long))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
186+
- (void)addProgressCallback:(void (^)(NSUInteger, NSUInteger))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: 2 additions & 2 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) long long expectedSize;
22+
@property (assign, nonatomic) NSUInteger 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, long long))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
39+
- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
4040
{
4141
if ((self = [super init]))
4242
{

0 commit comments

Comments
 (0)