Retain/Release/Autorelease macros for using non-ARC code with an ARC project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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