Use Xcode-debug and release modes, and xcode-debugrelease
In the development process, we often need to use NSLog to output some information, or even some development processes, which must be viewed in the console, experienced programmers can use the console to output the entire data interaction process. However, a published program contains too many NSLog outputs, which must have an impact on App performance. At this time, we can use a macro definition for processing and use the DEBUG mode during development, use the RELEASE mode during RELEASE. In this way, the published App will not output a large number of nslogs in the program.
The simple code is as follows,
?
1234 |
#if defined(DEBUG)||defined(_DEBUG) NSLog(@ "Test code" ); NSLog(@ "Test Coding" ); #endif |
The # if # endif macro above defines that if DEBUG is defined, NSLog output is used; otherwise, this code is ignored directly. Some people may wonder where the DEBUG and _ DEBUG come from. You don't have to worry about this. This is from the default setting of Xcode. We can cancel the DEBUG mode and enable the RELEASE mode, as shown below,
Choose Product> Scheme> Edit Scheme,
You can select Debug and Release modes,
If Release is selected here, no Debug is defined by default, the output NSLog between # if... # endif in the above Code will not be executed. In this way, resources of some hardware devices are saved when the program is released.