Authored by Olivier Poitrey

Fix crash under iOS 6 when dispatch_release is called (see #213)

@@ -91,7 +91,7 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week @@ -91,7 +91,7 @@ static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week
91 - (void)dealloc 91 - (void)dealloc
92 { 92 {
93 [[NSNotificationCenter defaultCenter] removeObserver:self]; 93 [[NSNotificationCenter defaultCenter] removeObserver:self];
94 - dispatch_release(_ioQueue); 94 + SDDispatchQueueRelease(_ioQueue);
95 } 95 }
96 96
97 #pragma mark SDImageCache (private) 97 #pragma mark SDImageCache (private)
@@ -33,6 +33,19 @@ @@ -33,6 +33,19 @@
33 #import <UIKit/UIKit.h> 33 #import <UIKit/UIKit.h>
34 #endif 34 #endif
35 35
  36 +// @see https://github.com/ccgus/fmdb/commit/aef763eeb64e6fa654e7d121f1df4c16a98d9f4f
  37 +#define SDDispatchQueueRelease(q) (dispatch_release(q))
  38 +
  39 +#if TARGET_OS_IPHONE
  40 + #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
  41 + #define SDDispatchQueueRelease(q)
  42 + #endif
  43 +#else
  44 + #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
  45 + #define SDDispatchQueueRelease(q)
  46 + #endif
  47 +#endif
  48 +
36 NS_INLINE UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData) 49 NS_INLINE UIImage *SDScaledImageForPath(NSString *path, NSObject *imageOrData)
37 { 50 {
38 if (!imageOrData) 51 if (!imageOrData)
@@ -77,8 +77,8 @@ NSString *const kCompletedCallbackKey = @"completed"; @@ -77,8 +77,8 @@ NSString *const kCompletedCallbackKey = @"completed";
77 - (void)dealloc 77 - (void)dealloc
78 { 78 {
79 [self.downloadQueue cancelAllOperations]; 79 [self.downloadQueue cancelAllOperations];
80 - dispatch_release(_workingQueue);  
81 - dispatch_release(_barrierQueue); 80 + SDDispatchQueueRelease(_workingQueue);
  81 + SDDispatchQueueRelease(_barrierQueue);
82 } 82 }
83 83
84 - (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads 84 - (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads