iOS Development note (one) iOS development NSLog use tips in xcode6.01 before there are prefix.pch files, Xcode6.01 will not have, but can create their own! Prerequisites:in Xcode to do development debugging often need to print some debugging information to do debug, we know that when the printing of information more places in the simulator run may not have any problems, Because the simulator uses the hardware of the computer but when the application runs on the device, these output statements will affect the performance of the application to a large extent, and for this problem, some macros can be written to control the output of these debugging information.
Disable output of NSLog content in release version
Because the output of the nslog is more expensive than the system resources, and the output data may also expose the confidential data in the app, so the release of the official version of the need to screen out all of the output.
It is a dull and time-consuming thing to comment out all the nslog statements before we release the version, and then cancel the comments when we want to debug them later. Fortunately, there is a more elegant solution, is to add the following piece of code in the project's prefix.pch file, after joining, NSLog only in the debug output, release under not output.
How to achieve: in-prefix.pch (PCH full name is "precompiled Header", that is, the precompiled header file, which is stored in the project some infrequently modified code, such as the usual framework header file, so that the purpose of improving the compiler speed. We know that when we modify a file code in a project, the compiler does not recompile all the files, but compiles the changed files, if a file in the PCH is modified, then the other files contained in the PCH file will be recompiled once, which will consume a lot of time. So it is better to add the file inside the header file that is rarely changed or not changed or is precompiled Code snippet;) file to add
[Plain]View Plaincopy
- #ifdef DEBUG
- #define NSLOG (...) NSLog (__va_args__)
- #define DEBUGMETHOD () NSLog (@ "%s", __func__)
- #else
- #define NSLOG (...)
- #define DEBUGMETHOD ()
- #endif
The above code means to make a judgment with the macro command, if the debug is true, then compile #ifdef to #endif macro definition, otherwise the compiler will not compile;
Where does this debug set up,
There is a "debug=1" in "Target > Build Settings > Preprocessor Macros > Debug".
set to debug mode, Product-->scheme-->schemeedit scheme
when you set the build configuration to debug, you can print the NSLog.
set up release, which will not print when the app version is published, improves performance
Use of IOS NSLog and the use of PCH