IPhone DevelopmentOnly compile in Debug modeNSLogIs the content to be introduced in this article, inIphone DevelopmentAnd debugging,NSLog() Is a very useful tool. However, even if the compilation configuration is set to Release,NSLog() Code will also be compiled into the final file, which is obviously not good news.
Using the macro feature of C, this problem can be easily solved.
Create a new Debug. h file with the following content:
- #ifdef DEBUG
- #define debug_NSLog(format, ...) NSLog(format, ## __VA_ARGS__)
- #else
- #define debug_NSLog(format, ...)
- #endif
Set the current Active configuration to Debug, select "Project-> Edit Active Target" from the menu, and open the Setting dialog box,
You can find the predefined macro In the Build tag. Here there should be a DEBUG item. If not, add it.
After this setting, the debug_NSLog () Macro will generate the actual code only when the Debug configuration is used for compilation.
PS: replace all NSLog () in the program with debug_NSLog ().
Summary:IPhone DevelopmentOnly compile in Debug modeNSLogI hope this article will help you!