以下のマクロ群を使えばARC設定を読み取って出し分けしてくれる。
# ifndef AH_RETAIN
# if __has_feature(objc_arc)
# define AH_RETAIN(x) x
# define AH_RELEASE(x)
# define AH_AUTORELEASE(x) x
# define AH_SUPER_DEALLOC
# else
# 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
# endif
ex)
UIView* view = [UIView alloc] init];
...
AH_AUTORELEASE(view);
- (void) dealloc
{
AH_SUPER_DEALLOC;
}