Dot-notation should always be used for accessing and mutating properties. Bracket notation is preferred in all other instances
This commit is contained in:
parent
6d8133557c
commit
bdea43aec1
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue