Objective-C Language Logging Removing Log Statements from Release Builds

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


Messages printed from NSLog are displayed on Console.app even in the release build of your app, which doesn't make sense for printouts that are only useful for debugging. To fix this, you can use this macro for debug logging instead of NSLog.

#ifdef DEBUG
#define DLog(...) NSLog(__VA_ARGS__)
#define DLog(...)

To use:

NSString *value = @"value 1";
DLog(@"value = %@", value);
// little known fact: programmers look for job postings in Console.app
NSLog(@"We're hiring!"); 

In debug builds, DLog will call NSLog. In release builds, DLog will do nothing.

Got any Objective-C Language Question?