Skip to content

Instantly share code, notes, and snippets.

@satoshin2071
Last active December 15, 2015 12:38
Show Gist options
  • Save satoshin2071/5261221 to your computer and use it in GitHub Desktop.
Save satoshin2071/5261221 to your computer and use it in GitHub Desktop.
xcode4でDEBUGのプリプロセッサマクロでDEBUGフラグの設定。とprefix.pchの設定。 ついでにRelease ビルドで NSLog() を無効化する
Build Settings > Apple LLVM compiler - Preprocessing > Preprocessor Macros
Debug: DEBUG=1
Release: (DEBUG未定義)
みたいな感じ設定
コード内で
// デバッグ用マクロ
#ifdef DEBUG
# define LOG(...) NSLog(__VA_ARGS__)
# define LOG_CURRENT_METHOD NSLog(@"METHOD: %@/%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd))
#else
# define LOG(...)
# define LOG_CURRENT_METHOD
#endif
// こんな漢字に使う
LOG_CURRENT_METHOD
LOG(@"soko")
// 端末のバージョン判定.
#define SYSTEM_VERSION_OVER_THAN(v) !([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
// iPhone/iPad判別.
#define isPhone ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment