不打印空消息

NSLog 被要求打印空字符串时,它会完全省略日志。

NSString *name = @"";
NSLog(@"%@", name);  // Resolves to @""

上面的代码什么都不打印。

使用标签为日志添加前缀是一种好习惯:

NSString *name = @"";
NSLog(@"Name: %@", name);  // Resolves to @"Name: "

上面的代码将打印:

2016-07-21 14:20:28.623 App[87711:6153103] Name: