The NSLog shielding Method for debug and release versions for iOS development, releasenslog
A Brief Introduction to the following macros: 1) _ VA_ARGS _ is a macro of a variable parameter. The macro of this variable parameter is added in the new C99 specification, currently, only gcc is supported (not supported by the VC6.0 compiler ). # Is added before the Macro. When the number of variable parameters is 0, # is used to remove ",". Otherwise, compilation errors may occur. 2) _ FILE _ macro is replaced with the current source FILE name during pre-compilation. 3) _ LINE _ macro is replaced with the current row number during pre-compilation. 4) _ FUNCTION _ macro is replaced with the current FUNCTION name during pre-compilation. in the ***-Prefix. add in pch and redefine the NSLog of the system. __optimize _ is the macro added by default by release # ifndef _ OPTIMIZE _ # define NSLog (...) NSLog (_ VA_ARGS _) # else # define NSLog (...) {}# endif 2. in the ***-Prefix. add in pch and write # define directly. When the release version is released, comment out # define IOS_DEBUG # ifdef IOS_DEBUG # define NSLog (...) NSLog (_ VA_ARGS _) # endif 3. in the ***-Prefix. add # ifdef DEBUG # define DLog (format,...) to pch ,...) NSLog (@ "[FILE Name: % s]" "[function name: % s]" "[line number: % d]" format), _ FILE __, _ FUNCTION __, _ LINE __, ##__ VA_ARGS _); # else # define DLog (...); # endif This method requires modifying the project configuration so that during debug compilation, DLog macros are compiled to generate detailed log information, while during release, it is more convenient than generating any console output.