From c28507432144cfe7673402bae62812bf8c501edf Mon Sep 17 00:00:00 2001 From: Ruslan Ahapkin Date: Thu, 3 Apr 2014 23:16:48 +0400 Subject: [PATCH] Create NSOperation when start operation. Method getDiskCount returns NSUInteger. --- SDWebImage/SDImageCache.h | 2 +- SDWebImage/SDImageCache.m | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SDWebImage/SDImageCache.h b/SDWebImage/SDImageCache.h index 2e1eed56..6fb9a198 100644 --- a/SDWebImage/SDImageCache.h +++ b/SDWebImage/SDImageCache.h @@ -172,7 +172,7 @@ typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType ca /** * Get the number of images in the disk cache */ -- (int)getDiskCount; +- (NSUInteger)getDiskCount; /** * Asynchronously calculate the disk cache's size. diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index 3f36e5e1..d8f3a97f 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -265,9 +265,9 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { } - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock { - NSOperation *operation = [NSOperation new]; - - if (!doneBlock) return nil; + if (!doneBlock) { + return nil; + } if (!key) { doneBlock(nil, SDImageCacheTypeNone); @@ -281,6 +281,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { return nil; } + NSOperation *operation = [NSOperation new]; dispatch_async(self.ioQueue, ^{ if (operation.isCancelled) { return; @@ -459,13 +460,11 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { return size; } -- (int)getDiskCount { - __block int count = 0; +- (NSUInteger)getDiskCount { + __block NSUInteger count = 0; dispatch_sync(self.ioQueue, ^{ NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; - for (__unused NSString *fileName in fileEnumerator) { - count += 1; - } + count = [[fileEnumerator allObjects] count]; }); return count; }