Skip to content

Commit

Permalink
Merge pull request #603 from akhenakh/64bits_support
Browse files Browse the repository at this point in the history
64bits support (fix #572, fix #504, fix #494)
  • Loading branch information
Olivier Poitrey committed Jan 6, 2014
2 parents 8f8228e + 77fad5c commit 853ad83
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ It provides:
- A guarantee that main thread will never be blocked
- Performances!
- Use GCD and ARC
- Arm64 support

NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.0
NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1
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).

[How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F)
Expand Down
17 changes: 15 additions & 2 deletions SDWebImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@
531041DE157EAFA400BBABC3 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -848,6 +849,7 @@
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
INSTALL_PATH = "$(BUILT_PRODUCTS_DIR)";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "SDWebImage+MKAnnotation";
SKIP_INSTALL = YES;
Expand All @@ -858,6 +860,7 @@
531041DF157EAFA400BBABC3 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -881,6 +884,7 @@
53761323155AD0D5005750A4 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -904,6 +908,7 @@
53761324155AD0D5005750A4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -927,6 +932,7 @@
537D95BF17ECC1FE0097C263 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
Expand Down Expand Up @@ -954,6 +960,7 @@
537D95C017ECC1FE0097C263 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = NO;
Expand All @@ -978,6 +985,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand All @@ -1001,7 +1009,7 @@
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = Vendors/libwebp/src;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PUBLIC_HEADERS_FOLDER_PATH = include/SDWebImage;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
Expand All @@ -1012,6 +1020,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
COPY_PHASE_STRIP = YES;
GCC_PREPROCESSOR_DEFINITIONS = "";
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
Expand All @@ -1029,7 +1038,7 @@
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = Vendors/libwebp/src;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PUBLIC_HEADERS_FOLDER_PATH = include/SDWebImage;
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
Expand All @@ -1040,13 +1049,17 @@
539F912D16316D2D00160719 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
539F912E16316D2D00160719 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
6 changes: 3 additions & 3 deletions SDWebImage/SDImageCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef enum SDImageCacheType SDImageCacheType;
/**
* The maximum size of the cache, in bytes.
*/
@property (assign, nonatomic) unsigned long long maxCacheSize;
@property (assign, nonatomic) NSUInteger maxCacheSize;

/**
* Returns global shared cache instance
Expand Down Expand Up @@ -153,7 +153,7 @@ typedef enum SDImageCacheType SDImageCacheType;
/**
* Get the size used by the disk cache
*/
- (unsigned long long)getSize;
- (NSUInteger)getSize;

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

/**
* Check if image exists in cache already
Expand Down
18 changes: 9 additions & 9 deletions SDWebImage/SDImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ - (void)cleanDisk

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

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

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

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

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

if (currentCacheSize < desiredCacheSize)
{
Expand Down Expand Up @@ -508,9 +508,9 @@ - (void)backgroundCleanDisk
});
}

- (unsigned long long)getSize
- (NSUInteger)getSize
{
unsigned long long size = 0;
NSUInteger size = 0;
NSDirectoryEnumerator *fileEnumerator = [[NSFileManager defaultManager] enumeratorAtPath:self.diskCachePath];
for (NSString *fileName in fileEnumerator)
{
Expand All @@ -533,14 +533,14 @@ - (int)getDiskCount
return count;
}

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

dispatch_async(self.ioQueue, ^
{
NSUInteger fileCount = 0;
unsigned long long totalSize = 0;
NSUInteger totalSize = 0;

NSFileManager *fileManager = [NSFileManager defaultManager];
NSDirectoryEnumerator *fileEnumerator = [fileManager enumeratorAtURL:diskCacheURL
Expand All @@ -552,7 +552,7 @@ - (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, unsigne
{
NSNumber *fileSize;
[fileURL getResourceValue:&fileSize forKey:NSURLFileSizeKey error:NULL];
totalSize += [fileSize unsignedLongLongValue];
totalSize += [fileSize unsignedIntegerValue];
fileCount += 1;
}

Expand Down
2 changes: 1 addition & 1 deletion SDWebImage/SDWebImageDownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef enum
extern NSString *const SDWebImageDownloadStartNotification;
extern NSString *const SDWebImageDownloadStopNotification;

typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, long long expectedSize);
typedef void(^SDWebImageDownloaderProgressBlock)(NSUInteger receivedSize, NSUInteger expectedSize);
typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished);

/**
Expand Down
6 changes: 3 additions & 3 deletions SDWebImage/SDWebImageDownloader.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ - (NSInteger)maxConcurrentDownloads
return _downloadQueue.maxConcurrentOperationCount;
}

- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, long long))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock
- (id<SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock
{
__block SDWebImageDownloaderOperation *operation;
__weak SDWebImageDownloader *wself = self;
Expand All @@ -139,7 +139,7 @@ - (NSInteger)maxConcurrentDownloads
{
request.allHTTPHeaderFields = wself.HTTPHeaders;
}
operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSUInteger receivedSize, long long expectedSize)
operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSUInteger receivedSize, NSUInteger expectedSize)
{
if (!wself) return;
SDWebImageDownloader *sself = wself;
Expand Down Expand Up @@ -183,7 +183,7 @@ - (NSInteger)maxConcurrentDownloads
return operation;
}

- (void)addProgressCallback:(void (^)(NSUInteger, long long))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
- (void)addProgressCallback:(void (^)(NSUInteger, NSUInteger))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.
if(url == nil)
Expand Down
4 changes: 2 additions & 2 deletions SDWebImage/SDWebImageDownloaderOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ @interface SDWebImageDownloaderOperation ()

@property (assign, nonatomic, getter = isExecuting) BOOL executing;
@property (assign, nonatomic, getter = isFinished) BOOL finished;
@property (assign, nonatomic) long long expectedSize;
@property (assign, nonatomic) NSUInteger expectedSize;
@property (strong, nonatomic) NSMutableData *imageData;
@property (strong, nonatomic) NSURLConnection *connection;
@property (strong, atomic) NSThread *thread;
Expand All @@ -36,7 +36,7 @@ @implementation SDWebImageDownloaderOperation
BOOL responseFromCached;
}

- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, long long))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
- (id)initWithRequest:(NSURLRequest *)request options:(SDWebImageDownloaderOptions)options progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(UIImage *, NSData *, NSError *, BOOL))completedBlock cancelled:(void (^)())cancelBlock
{
if ((self = [super init]))
{
Expand Down

0 comments on commit 853ad83

Please sign in to comment.