diff --git a/SDImageCache.m b/SDImageCache.m index 4d1a1aa..b5c4ac6 100644 --- a/SDImageCache.m +++ b/SDImageCache.m @@ -4,7 +4,7 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - */ + */ #import "SDImageCache.h" #import @@ -39,7 +39,7 @@ static SDImageCache *instance; // Init the disk cache NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); diskCachePath = [[[paths objectAtIndex:0] stringByAppendingPathComponent:@"ImageCache"] retain]; - + if (![[NSFileManager defaultManager] fileExistsAtPath:diskCachePath]) { [[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath attributes:nil]; @@ -52,13 +52,13 @@ static SDImageCache *instance; // Subscribe to app events [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning:) - name:UIApplicationDidReceiveMemoryWarningNotification + name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willTerminate) - name:UIApplicationWillTerminateNotification - object:nil]; + name:UIApplicationWillTerminateNotification + object:nil]; } return self; @@ -66,18 +66,18 @@ static SDImageCache *instance; - (void)dealloc { - [memCache release]; - [diskCachePath release]; - [cacheInQueue release]; + [memCache release], memCache = nil; + [diskCachePath release], diskCachePath = nil; + [cacheInQueue release], cacheInQueue = nil; [[NSNotificationCenter defaultCenter] removeObserver:self - name:UIApplicationDidReceiveMemoryWarningNotification - object:nil]; + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self - name:UIApplicationWillTerminateNotification - object:nil]; - + name:UIApplicationWillTerminateNotification + object:nil]; + [super dealloc]; } @@ -89,7 +89,7 @@ static SDImageCache *instance; { instance = [[SDImageCache alloc] init]; } - + return instance; } @@ -134,7 +134,7 @@ static SDImageCache *instance; [memCache setObject:image forKey:key]; if (toDisk) - { + { [cacheInQueue addOperation:[[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(storeKeyToDisk:) object:key] autorelease]]; } } @@ -187,7 +187,7 @@ static SDImageCache *instance; { [cacheInQueue cancelAllOperations]; [[NSFileManager defaultManager] removeItemAtPath:diskCachePath error:nil]; - [[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath attributes:nil]; + [[NSFileManager defaultManager] createDirectoryAtPath:diskCachePath attributes:nil]; } - (void)cleanDisk diff --git a/SDWebImageDownloader.m b/SDWebImageDownloader.m index 3fa1f46..5afaf18 100644 --- a/SDWebImageDownloader.m +++ b/SDWebImageDownloader.m @@ -16,7 +16,7 @@ static NSOperationQueue *downloadQueue; - (void)dealloc { - [url release]; + [url release], url = nil; [super dealloc]; } @@ -33,7 +33,7 @@ static NSOperationQueue *downloadQueue; } [downloadQueue addOperation:downloader]; - + return downloader; } @@ -54,7 +54,7 @@ static NSOperationQueue *downloadQueue; // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5]; UIImage *image = [UIImage imageWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:NULL]]; - + if (!self.isCancelled && [delegate respondsToSelector:@selector(imageDownloader:didFinishWithImage:)]) { [delegate performSelector:@selector(imageDownloader:didFinishWithImage:) withObject:self withObject:image]; diff --git a/SDWebImageManager.h b/SDWebImageManager.h index 99149e1..749f6b0 100644 --- a/SDWebImageManager.h +++ b/SDWebImageManager.h @@ -4,7 +4,7 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - */ + */ #import #import "SDWebImageDownloaderDelegate.h" diff --git a/SDWebImageManager.m b/SDWebImageManager.m index 9eca925..8f41fe5 100644 --- a/SDWebImageManager.m +++ b/SDWebImageManager.m @@ -4,7 +4,7 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - */ + */ #import "SDWebImageManager.h" #import "SDImageCache.h" @@ -26,12 +26,12 @@ static SDWebImageManager *instance; return self; } -- (void) dealloc +- (void)dealloc { - [delegates release]; - [downloaders release]; - [downloaderForURL release]; - [failedURLs release]; + [delegates release], delegates = nil; + [downloaders release], downloaders = nil; + [downloaderForURL release], downloaderForURL = nil; + [failedURLs release], failedURLs = nil; [super dealloc]; } @@ -86,7 +86,7 @@ static SDWebImageManager *instance; } SDWebImageDownloader *downloader = [[downloaders objectAtIndex:idx] retain]; - + [delegates removeObjectAtIndex:idx]; [downloaders removeObjectAtIndex:idx]; diff --git a/UIImageView+WebCache.h b/UIImageView+WebCache.h index fa153db..376269d 100644 --- a/UIImageView+WebCache.h +++ b/UIImageView+WebCache.h @@ -4,7 +4,7 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - */ + */ #import #import "SDWebImageManagerDelegate.h" diff --git a/UIImageView+WebCache.m b/UIImageView+WebCache.m index b23f9cd..60655ad 100644 --- a/UIImageView+WebCache.m +++ b/UIImageView+WebCache.m @@ -4,7 +4,7 @@ * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. - */ + */ #import "UIImageView+WebCache.h" #import "SDWebImageManager.h" @@ -45,4 +45,4 @@ self.image = image; } -@end \ No newline at end of file +@end