Skip to content

Instantly share code, notes, and snippets.

@kishorek
Forked from mikekppp/ARCHelper.h
Created May 14, 2013 06:30
Show Gist options
  • Save kishorek/5574075 to your computer and use it in GitHub Desktop.
Save kishorek/5574075 to your computer and use it in GitHub Desktop.
//
// ARCHelper.h
//
// Version 1.2.1
//
// Created by Nick Lockwood on 05/01/2012.
// Copyright 2012 Charcoal Design
//
// Distributed under the permissive zlib license
// Get the latest version from here:
//
// https://gist.github.com/1563325
//
#ifndef AH_RETAIN
#if __has_feature(objc_arc) // has ARC
#define AH_RETAIN(x) (x)
#define AH_RELEASE(x)
#define AH_AUTORELEASE(x) (x)
#define AH_SUPER_DEALLOC
#else // no ARC
#define __AH_WEAK
#define AH_WEAK assign
#define AH_RETAIN(x) [(x) retain]
#define AH_RELEASE(x) [(x) release]
#define AH_AUTORELEASE(x) [(x) autorelease]
#define AH_SUPER_DEALLOC [super dealloc]
#endif // __has_feature(objc_arc)
#endif // AH_RETAIN
// Weak reference support
#ifndef AH_WEAK
#if defined __IPHONE_OS_VERSION_MIN_REQUIRED
#if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3 // iOS
#define __AH_WEAK __weak
#define AH_WEAK weak
#else
#define __AH_WEAK __unsafe_unretained
#define AH_WEAK unsafe_unretained
#endif // __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_4_3
#elif defined __MAC_OS_X_VERSION_MIN_REQUIRED
#if __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_6 // Mac
#define __AH_WEAK __weak
#define AH_WEAK weak
#else
#define __AH_WEAK __unsafe_unretained
#define AH_WEAK unsafe_unretained
#endif // __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_6
#endif //__MAC_OS_X_VERSION_MIN_REQUIRED
#endif // AH_WEAK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment