Permalink
Browse files

Dot-notation should always be used for accessing and mutating propert…

…ies. Bracket notation is preferred in all other instances
  • Loading branch information...
1 parent 6d81335 commit bdea43aec17ec4f61002cfc0008a66b5c2eedddc @akhenakh akhenakh committed Jan 7, 2014
View
@@ -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 @@ + (SDImageCache *)sharedImageCache {
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 @@ - (id)initWithNamespace:(NSString *)ns {
_diskCachePath = [paths[0] stringByAppendingPathComponent:fullNamespace];
dispatch_sync(_ioQueue, ^{
- _fileManager = NSFileManager.new;
+ _fileManager = [NSFileManager new];
});
#if TARGET_OS_IPHONE
@@ -108,7 +108,7 @@ - (void)dealloc {
- (void)addReadOnlyCachePath:(NSString *)path {
if (!self.customPaths) {
- self.customPaths = NSMutableArray.new;
+ self.customPaths = [NSMutableArray new];
}
if (![self.customPaths containsObject:path]) {
@@ -182,7 +182,7 @@ - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate image
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 @@ - (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image {
}
- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock {
- NSOperation *operation = NSOperation.new;
+ NSOperation *operation = [NSOperation new];
if (!doneBlock) return nil;
@@ -56,17 +56,17 @@ + (SDWebImageDownloader *)sharedDownloader {
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])) {
_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 @@ - (NSInteger)maxConcurrentDownloads {
}
// 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 @@ - (NSInteger)maxConcurrentDownloads {
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 @@ - (void)addProgressCallback:(void (^)(NSInteger, NSInteger))progressBlock andCom
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 @@ - (void)start {
#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 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLRespon
self.progressBlock(0, expected);
}
- self.imageData = [NSMutableData.alloc initWithCapacity:expected];
+ self.imageData = [[NSMutableData alloc] initWithCapacity:expected];
}
else {
[self.connection cancel];
@@ -32,17 +32,17 @@ + (id)sharedManager {
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])) {
_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 @@ - (BOOL)diskImageExistsForURL:(NSURL *)url {
url = nil;
}
- __block SDWebImageCombinedOperation *operation = SDWebImageCombinedOperation.new;
+ __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new];
__weak SDWebImageCombinedOperation *weakOperation = operation;
BOOL isFailedUrl = NO;
@@ -26,14 +26,14 @@ + (SDWebImagePrefetcher *)sharedImagePrefetcher {
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;
}

0 comments on commit bdea43a

Please sign in to comment.