Skip to content

Instantly share code, notes, and snippets.

@mazgi
Created June 3, 2012 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazgi/2863258 to your computer and use it in GitHub Desktop.
Save mazgi/2863258 to your computer and use it in GitHub Desktop.
デバッグLOG出力
#ifdef DEBUG
extern void _objc_autoreleasePoolPrint();
#define _objc_autoreleasePoolPrint() _objc_autoreleasePoolPrint()
#define __BASENAME__ (strrchr(__FILE__, '/') + 1)
/*!
@define
@abstract デバッグ時のみ出力されるログ
@param 第一引数はフォーマット文字列、以降可変引数
*/
#define LOG(...) \
NSLog(@"%s(%s:%05d)%@", __PRETTY_FUNCTION__, __BASENAME__, __LINE__, [NSString stringWithFormat:__VA_ARGS__])
/*!
@define
@abstract UIViewの全階層を辿り文字列として返す
@param view ダンプしたいViewインスタンス
@result ダンプ文字列
*/
#define ViewDump(view) \
([view respondsToSelector:@selector(recursiveDescription)])?[view performSelector:@selector(recursiveDescription)]:@""
#else
#define _objc_autoreleasePoolPrint()
#define LOG(...)
#define ViewDump(view)
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment