diff --git a/README.md b/README.md index fb9f79c..95ac0bd 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ key is an application unique identifier for the image to cache. It is generally the image. ```objective-c -SDImageCache *imageCache = [SDImageCache.alloc initWithNamespace:@"myNamespace"]; +SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"]; [imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image) { // image is not nil if image was found diff --git a/SDWebImage/SDImageCache.m b/SDWebImage/SDImageCache.m index c391bb2..d1f44c5 100644 --- a/SDWebImage/SDImageCache.m +++ b/SDWebImage/SDImageCache.m @@ -47,7 +47,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { static dispatch_once_t once; static id instance; dispatch_once(&once, ^{ - instance = self.new; + instance = [self new]; kPNGSignatureData = [NSData dataWithBytes:kPNGSignatureBytes length:8]; }); return instance; @@ -76,7 +76,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { _diskCachePath = [paths[0] stringByAppendingPathComponent:fullNamespace]; dispatch_sync(_ioQueue, ^{ - _fileManager = NSFileManager.new; + _fileManager = [NSFileManager new]; }); #if TARGET_OS_IPHONE @@ -108,7 +108,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { - (void)addReadOnlyCachePath:(NSString *)path { if (!self.customPaths) { - self.customPaths = NSMutableArray.new; + self.customPaths = [NSMutableArray new]; } if (![self.customPaths containsObject:path]) { @@ -182,7 +182,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { if (data) { // Can't use defaultManager another thread - NSFileManager *fileManager = NSFileManager.new; + NSFileManager *fileManager = [NSFileManager new]; if (![fileManager fileExistsAtPath:_diskCachePath]) { [fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; @@ -268,7 +268,7 @@ BOOL ImageDataHasPNGPreffix(NSData *data) { } - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock { - NSOperation *operation = NSOperation.new; + NSOperation *operation = [NSOperation new]; if (!doneBlock) return nil; diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index e856ab2..b858aca 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -56,7 +56,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; static dispatch_once_t once; static id instance; dispatch_once(&once, ^{ - instance = self.new; + instance = [self new]; }); return instance; } @@ -64,9 +64,9 @@ static NSString *const kCompletedCallbackKey = @"completed"; - (id)init { if ((self = [super init])) { _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; - _downloadQueue = NSOperationQueue.new; + _downloadQueue = [NSOperationQueue new]; _downloadQueue.maxConcurrentOperationCount = 2; - _URLCallbacks = NSMutableDictionary.new; + _URLCallbacks = [NSMutableDictionary new]; _HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"]; _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); _downloadTimeout = 15.0; @@ -115,7 +115,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; } // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise - NSMutableURLRequest *request = [NSMutableURLRequest.alloc initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); request.HTTPShouldUsePipelining = YES; if (wself.headersFilter) { @@ -124,7 +124,7 @@ static NSString *const kCompletedCallbackKey = @"completed"; else { request.allHTTPHeaderFields = wself.HTTPHeaders; } - operation = [SDWebImageDownloaderOperation.alloc initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) { + operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request options:options progress:^(NSInteger receivedSize, NSInteger expectedSize) { if (!wself) return; SDWebImageDownloader *sself = wself; NSArray *callbacksForURL = [sself callbacksForURL:url]; @@ -173,13 +173,13 @@ static NSString *const kCompletedCallbackKey = @"completed"; dispatch_barrier_sync(self.barrierQueue, ^{ BOOL first = NO; if (!self.URLCallbacks[url]) { - self.URLCallbacks[url] = NSMutableArray.new; + self.URLCallbacks[url] = [NSMutableArray new]; first = YES; } // Handle single download of simultaneous download request for the same URL NSMutableArray *callbacksForURL = self.URLCallbacks[url]; - NSMutableDictionary *callbacks = NSMutableDictionary.new; + NSMutableDictionary *callbacks = [NSMutableDictionary new]; if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; [callbacksForURL addObject:callbacks]; diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 404e3e9..1ab7713 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -75,7 +75,7 @@ #endif self.executing = YES; - self.connection = [NSURLConnection.alloc initWithRequest:self.request delegate:self startImmediately:NO]; + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; self.thread = [NSThread currentThread]; } @@ -184,7 +184,7 @@ self.progressBlock(0, expected); } - self.imageData = [NSMutableData.alloc initWithCapacity:expected]; + self.imageData = [[NSMutableData alloc] initWithCapacity:expected]; } else { [self.connection cancel]; diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index 6d7f075..312b3e7 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -32,7 +32,7 @@ static dispatch_once_t once; static id instance; dispatch_once(&once, ^{ - instance = self.new; + instance = [self new]; }); return instance; } @@ -40,9 +40,9 @@ - (id)init { if ((self = [super init])) { _imageCache = [self createCache]; - _imageDownloader = SDWebImageDownloader.new; - _failedURLs = NSMutableArray.new; - _runningOperations = NSMutableArray.new; + _imageDownloader = [SDWebImageDownloader new]; + _failedURLs = [NSMutableArray new]; + _runningOperations = [NSMutableArray new]; } return self; } @@ -80,7 +80,7 @@ url = nil; } - __block SDWebImageCombinedOperation *operation = SDWebImageCombinedOperation.new; + __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new]; __weak SDWebImageCombinedOperation *weakOperation = operation; BOOL isFailedUrl = NO; diff --git a/SDWebImage/SDWebImagePrefetcher.m b/SDWebImage/SDWebImagePrefetcher.m index 7d0383c..d41500b 100644 --- a/SDWebImage/SDWebImagePrefetcher.m +++ b/SDWebImage/SDWebImagePrefetcher.m @@ -26,14 +26,14 @@ static dispatch_once_t once; static id instance; dispatch_once(&once, ^{ - instance = self.new; + instance = [self new]; }); return instance; } - (id)init { if ((self = [super init])) { - _manager = SDWebImageManager.new; + _manager = [SDWebImageManager new]; _options = SDWebImageLowPriority; self.maxConcurrentDownloads = 3; }