IOS: #ifdef DEBUG

Source: Internet
Author: User

Development, often used to NSLog, but release is also want to clear off all NSLog, method is: in xxx-prefix.pch add

[CPP]View Plaincopy
    1. #ifdef DEBUG
    2. # define DLOG (...) NSLog (__va_args__)
    3. #else
    4. # define DLOG (...)/* */
    5. #endif
    6. #define ALOG (...) NSLog (__va_args__)


When your want to log is only in the debug builds use DLog (). In release builds DLog () would be compiled as an empty comment. Otherwise use ALog () for logging in both debug and release builds. (A as in always.)

So where does "DEBUG" define? There is a "debug=1" in "Target > Build Settings > Preprocessor Macros > Debug".

When you run, Test, analyze, it belongs to debug mode, when profile, archive is the release mode. See "Edit Scheme ..." in your iOS project

Another use of #ifdef DEBUG is: for push notification. Sandbox device token and production device token must not mix together, otherwise there may be some device not receiving. See http://blog.csdn.net/totogogo/article/details/8035095

So we need to prepare 2 URLs for reg device token

[CPP]View Plaincopy
      1. #ifdef  debug  
      2.     nsstring *  Const reg_ur[email protected] "Http://xxxx/reg_dev_token";   
      3. #else   
      4.      nsstring * const [email protected]
      5. #endif   

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.