5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[手記]XcodeのARC設定の有無によってRelease処理の出し分けを行うマクロ

Last updated at Posted at 2014-06-09

以下のマクロ群を使えば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;
}

こちらより
https://gist.github.com/nicklockwood/1563325

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?