不廢話 直接上代碼:
如果不想改變NSLOG輸出就這樣寫(xiě)
//如果release狀態(tài)就不執(zhí)行NSLog函數(shù)
#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#else
# define NSLog(...) {}
#endif
自定義:
#ifdef DEBUG
#define HYLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define HYLog(...)
#endif
xcode 8真機(jī)測(cè)試 打印字符串
#ifdef DEBUG
#define HYString [NSString stringWithFormat:@"%s", __FILE__].lastPathComponent
#define HY_Log(...) printf("%s: %s 第%d行: %s\n\n",[hy_stringDate UTF8String], [HYString UTF8String] ,__LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String])
#else
#define HY_Log(...)
#endif
親測(cè)有用嬉愧。贩挣。。英染。揽惹。。四康。搪搏。。闪金。