File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99#import " JMImageCache.h"
1010
11- static NSString *_JMImageCacheDirectory;
12-
1311static inline NSString *JMImageCacheDirectory () {
14- if (!_JMImageCacheDirectory) {
12+ static NSString *_JMImageCacheDirectory;
13+ static dispatch_once_t onceToken;
14+
15+ dispatch_once (&onceToken, ^{
1516 _JMImageCacheDirectory = [[NSHomeDirectory () stringByAppendingPathComponent: @" Library/Caches/JMCache" ] copy ];
16- }
17+ });
1718
1819 return _JMImageCacheDirectory;
1920}
2526 return [JMImageCacheDirectory () stringByAppendingPathComponent: fileName];
2627}
2728
28- JMImageCache *_sharedCache = nil ;
29-
3029@interface JMImageCache ()
3130
3231@property (strong , nonatomic ) NSOperationQueue *diskOperationQueue;
@@ -40,9 +39,12 @@ @implementation JMImageCache
4039@synthesize diskOperationQueue = _diskOperationQueue;
4140
4241+ (JMImageCache *) sharedCache {
43- if (!_sharedCache) {
42+ static JMImageCache *_sharedCache = nil ;
43+ static dispatch_once_t onceToken;
44+
45+ dispatch_once (&onceToken, ^{
4446 _sharedCache = [[JMImageCache alloc ] init ];
45- }
47+ });
4648
4749 return _sharedCache;
4850}
You can’t perform that action at this time.
0 commit comments