Don't use dispatch_release() under ARC in OS X 10.8 or iOS 6.0 and later

This commit is contained in:
Pierre-Olivier Latour 2014-01-23 11:33:33 -08:00
parent 965e111280
commit 7c8205caa0
3 changed files with 11 additions and 3 deletions

View File

@ -282,7 +282,7 @@ static void _NetServiceClientCallBack(CFNetServiceRef service, CFStreamError* er
}
dispatch_source_cancel(_source); // This will close the socket
dispatch_release(_source);
ARC_DISPATCH_RELEASE(_source);
_source = NULL;
LOG_VERBOSE(@"%@ stopped", [self class]);

View File

@ -201,7 +201,7 @@ static dispatch_queue_t _formatterQueue = NULL;
#endif
});
[self _writeBuffer:buffer withCompletionBlock:block];
dispatch_release(buffer);
ARC_DISPATCH_RELEASE(buffer);
}
- (void)_writeHeadersWithCompletionBlock:(WriteHeadersCompletionBlock)block {
@ -226,7 +226,7 @@ static dispatch_queue_t _formatterQueue = NULL;
}
}];
dispatch_release(wrapper);
ARC_DISPATCH_RELEASE(wrapper);
} else if (result < 0) {
LOG_ERROR(@"Failed reading response body on socket %i (error %i)", _socket, (int)result);
block(NO);

View File

@ -25,6 +25,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <TargetConditionals.h>
#if __has_feature(objc_arc)
#define ARC_BRIDGE __bridge
#define ARC_BRIDGE_RELEASE(__OBJECT__) CFBridgingRelease(__OBJECT__)
@ -32,6 +34,11 @@
#define ARC_RELEASE(__OBJECT__)
#define ARC_AUTORELEASE(__OBJECT__) __OBJECT__
#define ARC_DEALLOC(__OBJECT__)
#if (TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)) || (!TARGET_OS_IPHONE && (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8))
#define ARC_DISPATCH_RELEASE(__OBJECT__)
#else
#define ARC_DISPATCH_RELEASE(__OBJECT__) dispatch_release(__OBJECT__)
#endif
#else
#define ARC_BRIDGE
#define ARC_BRIDGE_RELEASE(__OBJECT__) [(id)__OBJECT__ autorelease]
@ -39,6 +46,7 @@
#define ARC_RELEASE(__OBJECT__) [__OBJECT__ release]
#define ARC_AUTORELEASE(__OBJECT__) [__OBJECT__ autorelease]
#define ARC_DEALLOC(__OBJECT__) [__OBJECT__ dealloc]
#define ARC_DISPATCH_RELEASE(__OBJECT__) dispatch_release(__OBJECT__)
#endif
#import "GCDWebServerConnection.h"