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
- #ifdef DEBUG
- # define DLOG (...) NSLog (__va_args__)
- #else
- # define DLOG (...)/* */
- #endif
- #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
- #ifdef debug
- nsstring * Const reg_ur[email protected] "Http://xxxx/reg_dev_token";
- #else
- nsstring * const [email protected]
- #endif