LoginSignup
16
15

More than 5 years have passed since last update.

NSLogマクロ

Last updated at Posted at 2013-02-21

他の方が、NSLogマクロを投稿してらしたので便乗して、
自分が使用してるマクロも公開

//  Objective-C
#ifdef __OBJC__

//  debugでしかログを出さない
#ifdef DEBUG 
#define __DISPLAY_LOGS__
#endif

#ifdef __DISPLAY_LOGS__
#define NSLogCGAffineTransform(x) NSLog(@"CGAffineTransform : %@", NSStringFromCGAffineTransform(x))
#define NSLogCGPoint(x) NSLog(@"CGPoint : %@", NSStringFromCGPoint(x))
#define NSLogCGRect(x) NSLog(@"CGRect : %@", NSStringFromCGRect(x))
#define NSLogCGSize(x) NSLog(@"CGSize : %@", NSStringFromCGSize(x))
#define NSLogClass(x) NSLog(@"Class : %@", NSStringFromClass(x))
#define NSLogProtocol(x) NSLog(@"Protocol : %@", NSStringFromProtocol(x))
#define NSLogRange(x) NSLog(@"Range : %@", NSStringFromRange(x))
#define NSLogSelector(x) NSLog(@"Selector : %@", NSStringFromSelector(x))
#define NSLogUIEdgeInsets(x) NSLog(@"UIEdgeInsets : %@", NSStringFromUIEdgeInsets(x))

#else
#define NSLogCGAffineTransform(x) ;
#define NSLogCGPoint(x) ;
#define NSLogCGRect(x) ;
#define NSLogCGSize(x) ;
#define NSLogClass(x) ;
#define NSLogProtocol(x) ;
#define NSLogRange(x) ;
#define NSLogSelector(x) ;
#define NSLogUIEdgeInsets(x) ;
#define NSLog(m, args...) ;
#endif

#endif

こんな感じのを、ヘッダーに纏めて
そのヘッダーファイルを、prefixで読み込ませて使用してます。

16
15
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
16
15