Refactoring macros for dispatch_release/retain fixes
Fixing macro for changed method signature for imp_implementationWithBlock(), which actually depends on Xcode version (and thus a check for either __IPHONE_6_0 or __MAC_10_8 to be defined,regardless of the deployment target
This commit is contained in:
parent
f12c163df9
commit
8c536f5f8d
2 changed files with 20 additions and 41 deletions
|
|
@ -40,20 +40,10 @@
|
|||
#import <netdb.h>
|
||||
#endif
|
||||
|
||||
// Does ARC support support GCD objects?
|
||||
// It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
|
||||
#if TARGET_OS_IPHONE
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
||||
#else // iOS 5.X or earlier
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
|
||||
#endif
|
||||
#else
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
||||
#else
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
|
||||
#endif
|
||||
// Workaround for management of dispatch_retain() / dispatch_release() by ARC with iOS 6 / Mac OS X 10.8
|
||||
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \
|
||||
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8))
|
||||
#define AF_DISPATCH_RETAIN_RELEASE 1
|
||||
#endif
|
||||
|
||||
@interface AFMultipartFormData : NSObject <AFMultipartFormData>
|
||||
|
|
@ -338,8 +328,7 @@ static const void * AFNetworkReachabilityRetainCallback(const void *info) {
|
|||
return (__bridge_retained const void *)([(__bridge AFNetworkReachabilityStatusBlock)info copy]);
|
||||
}
|
||||
|
||||
static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
||||
}
|
||||
static void AFNetworkReachabilityReleaseCallback(const void *info) {}
|
||||
|
||||
- (void)startMonitoringNetworkReachability {
|
||||
[self stopMonitoringNetworkReachability];
|
||||
|
|
@ -563,7 +552,7 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {
|
|||
completionBlock(operations);
|
||||
}
|
||||
});
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_release(dispatchGroup);
|
||||
#endif
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -23,27 +23,17 @@
|
|||
#import "AFHTTPRequestOperation.h"
|
||||
#import <objc/runtime.h>
|
||||
|
||||
// Workaround for change in imp_implementationWithBlock()
|
||||
#ifdef __IPHONE_6_0
|
||||
#define AF_CAST_TO_BLOCK id
|
||||
// Workaround for change in imp_implementationWithBlock() with Xcode 4.5
|
||||
#if defined(__IPHONE_6_0) || defined(__MAC_10_8)
|
||||
#define AF_CAST_TO_BLOCK id
|
||||
#else
|
||||
#define AF_CAST_TO_BLOCK __bridge void *
|
||||
#define AF_CAST_TO_BLOCK __bridge void *
|
||||
#endif
|
||||
|
||||
// Does ARC support support GCD objects?
|
||||
// It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
|
||||
#if TARGET_OS_IPHONE
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
||||
#else // iOS 5.X or earlier
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
|
||||
#endif
|
||||
#else
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
|
||||
#else
|
||||
#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier
|
||||
#endif
|
||||
// Workaround for management of dispatch_retain() / dispatch_release() by ARC with iOS 6 / Mac OS X 10.8
|
||||
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \
|
||||
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8))
|
||||
#define AF_DISPATCH_RETAIN_RELEASE 1
|
||||
#endif
|
||||
|
||||
NSSet * AFContentTypesFromHTTPHeader(NSString *string) {
|
||||
|
|
@ -134,14 +124,14 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
|
|||
|
||||
- (void)dealloc {
|
||||
if (_successCallbackQueue) {
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_release(_successCallbackQueue);
|
||||
#endif
|
||||
_successCallbackQueue = NULL;
|
||||
}
|
||||
|
||||
if (_failureCallbackQueue) {
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_release(_failureCallbackQueue);
|
||||
#endif
|
||||
_failureCallbackQueue = NULL;
|
||||
|
|
@ -224,14 +214,14 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
|
|||
- (void)setSuccessCallbackQueue:(dispatch_queue_t)successCallbackQueue {
|
||||
if (successCallbackQueue != _successCallbackQueue) {
|
||||
if (_successCallbackQueue) {
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_release(_successCallbackQueue);
|
||||
#endif
|
||||
_successCallbackQueue = NULL;
|
||||
}
|
||||
|
||||
if (successCallbackQueue) {
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_retain(successCallbackQueue);
|
||||
#endif
|
||||
_successCallbackQueue = successCallbackQueue;
|
||||
|
|
@ -242,14 +232,14 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) {
|
|||
- (void)setFailureCallbackQueue:(dispatch_queue_t)failureCallbackQueue {
|
||||
if (failureCallbackQueue != _failureCallbackQueue) {
|
||||
if (_failureCallbackQueue) {
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_release(_failureCallbackQueue);
|
||||
#endif
|
||||
_failureCallbackQueue = NULL;
|
||||
}
|
||||
|
||||
if (failureCallbackQueue) {
|
||||
#if NEEDS_DISPATCH_RETAIN_RELEASE
|
||||
#if AF_DISPATCH_RETAIN_RELEASE
|
||||
dispatch_retain(failureCallbackQueue);
|
||||
#endif
|
||||
_failureCallbackQueue = failureCallbackQueue;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue