iOS development Debug and release version NSLog shielding method

Source: Internet
Author: User

A brief introduction to the following macros: 1)  __VA_ARGS__  is a variable-parameter macro, which is a new C99 specification, and currently appears to be supported only by GCC (VC6.0 compiler does not support it). The macro front Plus # #的作用在于, when the number of variable parameters is 0 o'clock, here the # #起到把前面多余的 "," removed, otherwise it will compile error. 2)  __FILE__  macros are replaced with the current source file name at the time of precompilation 3)  __line__ macros are replaced with the current line number 4 at precompilation)  __function__ macros are replaced with the current function name 1 at precompilation.   Adding,  in ***-prefix.pch nslog,__optimize__  is the release  default add macro #ifndef __optimize__   #define  NSLOG (...)  nslog (__va_args__)   #else   #define  NSLOG (...) {}  #endif  2. Add   in ***-prefix.pch, write your own # define, and #define  comment out when release version #define ios_ debug#ifdef ios_debug  #define  NSLOG (...)  nslog (__va_args__)   #endif  3. Add #ifdef debug   # define in ***-prefix.pch  dlog (format,  ...)  nslog (@ "[File name:%s]"   [function name:%s] "  [line number:%d]"  format),  __file__, __function__, _ _line__, # #__VA_ARGS__);    #else    # define dlog (...);     #endif     This approach requires modifying the configuration of the project,Make in debug compile time, compile Dlog macro, generate verbose log information, and release when, do not produce any console output compared, or is the first kind of more convenient

iOS Development Debug and release version NSLog masking method

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.