不列印空訊息

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: