The NSLog shielding Method for debug and release versions for iOS development, releasenslog

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.