Retain/Release/Autorelease macros for using non-ARC code with an ARC project.
#ifdef __OBJC__ | |
#ifndef WBRetain | |
#if __has_feature(objc_arc) | |
# define WBRetain(obj) obj | |
#else | |
# define WBRetain(obj) [obj retain] | |
#endif | |
#endif | |
#ifndef WBRelease | |
#if __has_feature(objc_arc) | |
# define WBRelease(obj) | |
#else | |
# define WBRelease(obj) [obj release], obj = nil | |
#endif | |
#endif | |
#ifndef WBAutorelease | |
#if __has_feature(objc_arc) | |
# define WBAutorelease(obj) obj | |
#else | |
# define WBAutorelease(obj) [obj autorelease] | |
#endif | |
#endif | |
#ifndef WBSuperDealloc | |
// replace '[super dealloc];' in 'dealloc' body with this macro | |
// ie | |
// - (void)dealloc | |
// { | |
// WBRelease(ivar1); | |
// WBRelease(ivar2); | |
// WBSuperDealloc; | |
// } | |
// | |
#if __has_feature(objc_arc) | |
# define WBSuperDealloc [super dealloc] | |
#else | |
# define WBSuperDealloc | |
#endif | |
#endif | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment