diff --git a/Alcatraz/Helpers/ATZDownloader.m b/Alcatraz/Helpers/ATZDownloader.m index c86b9f7..6a9f32b 100644 --- a/Alcatraz/Helpers/ATZDownloader.m +++ b/Alcatraz/Helpers/ATZDownloader.m @@ -25,7 +25,7 @@ @interface ATZDownloader() @property (strong, nonatomic) NSMutableDictionary *callbacks; -@property (strong, nonatomic) NSURLSession *urlSession; +@property (strong, nonatomic, readonly) NSURLSession *urlSession; @end @@ -135,16 +135,14 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task #pragma mark - Private - (NSURLSession *)urlSession { - if (_urlSession) return _urlSession; - - _urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] - delegate:self - delegateQueue:[NSOperationQueue mainQueue]]; - return _urlSession; + static dispatch_once_t onceToken; + static NSURLSession *session = nil; + dispatch_once(&onceToken, ^{ + session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] + delegate:self + delegateQueue:[NSOperationQueue mainQueue]]; + }); + return session; } - - - - @end diff --git a/Alcatraz/Helpers/ATZStyleKit.m b/Alcatraz/Helpers/ATZStyleKit.m index 87cae54..8935a4d 100644 --- a/Alcatraz/Helpers/ATZStyleKit.m +++ b/Alcatraz/Helpers/ATZStyleKit.m @@ -99,6 +99,7 @@ + (void)drawText:(NSString*)text withColor:(NSColor *)color centeredInRect:(NSRe CGPathRef clippingPath = CGPathCreateWithRect(clippingRect, NULL); CGContextAddPath(context, clippingPath); CGContextClip(context); + CFRelease(clippingPath); NSMutableParagraphStyle* textStyle = NSMutableParagraphStyle.defaultParagraphStyle.mutableCopy; textStyle.alignment = NSCenterTextAlignment;