小伙伴反應(yīng)有時(shí)候控制臺(tái)打印json
內(nèi)容不全
如下圖
- 這是之前用的盔几,如下
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
改成了愕秫,如下
#ifdef DEBUG
// #import <UIKit/UIKit.h>
#define NSLog(FORMAT, ...) printf("%s %s: %s: %d\t%s\n\n", [((id(*)(void))method_getImplementation(class_getClassMethod(NSObject.class, @selector(ff_getConsoleLogOfTime))))() UTF8String], [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] UTF8String], [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif
ff_getConsoleLogOfTime
是放在NSObject
分類中
+ (NSString *)ff_getConsoleLogOfTime {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
return [dateFormatter stringFromDate:[NSDate date]];
}
- 但是報(bào)錯(cuò),如下
因?yàn)闆]有找到對(duì)應(yīng)的定義关摇,導(dǎo)入頭文件即可#import <UIKit/UIKit.h>
- 修改完成后奶赔,重新編譯發(fā)現(xiàn)許多警告
這是因?yàn)樵谑褂眠@個(gè)宏的時(shí)候,當(dāng)前文件沒有找到這個(gè)方法
- 我們可以忽略這個(gè)警告
方法1:這種方式需要在每個(gè)NSLog
顯式指定編譯器忽略該警告痰滋,麻煩摘能,棄之
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
NSLog(@"用戶未錄入指紋");
#pragma clang diagnostic pop
方法2:Undeclared Selector
改為 No
方法3:Other Warning Flags
添加 -Wno-undeclared-selector
三種方法都行续崖,我選第二種,不要問為什么团搞,因?yàn)閼醒贤
version
不定期更新 不合適的地方 還請指點(diǎn)~ 感激不盡