iOS: #ifdef DEBUG

news/2024/7/5 10:21:51

开发时,经常用到NSLog,但release是又想一次过清掉all NSLog,方法是:在xxx-Prefix.pch里添加

[cpp]  view plain copy
  1. #ifdef DEBUG  
  2. #    define DLog(...) NSLog(__VA_ARGS__)  
  3. #else  
  4. #    define DLog(...) /* */  
  5. #endif  
  6. #define ALog(...) NSLog(__VA_ARGS__)  

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


那么"DEBUG"在哪里定义的呢? 在 "Target > Build Settings > Preprocessor Macros > Debug" 里有一个"DEBUG=1"。


你Run, Test, Analyze时,就属于debug mode,当Profile, Archive时就属于release mode。见你的ios project的"Edit Scheme..."


#ifdef DEBUG的另外一个用处是:用于push notification。sandbox device token and production device token一定不能mix在一起,否则就可能有些device收不到。见http://blog.csdn.net/totogogo/article/details/8035095


因此我们需要为reg device token准备2个url

[cpp]  view plain copy
  1. #ifdef DEBUG  
  2.     NSString * const REG_URL=@"http://xxxx/reg_dev_token";  
  3. #else  
  4.     NSString * const REG_URL=@"http://xxxx/reg_production_token";  
  5. #endif  

http://www.niftyadmin.cn/n/593962.html

相关文章

《Web性能测试实战》“2006最受读者喜爱”十大开发类技术图书第12名

<iframe align"top" marginwidth"0" marginheight"0" src"http://www.zealware.com/csdnblog01.html" frameborder"0" width"728" scrolling"no" height"90"></iframe>高兴的是上…

card如何添加复选框 vant_vue+vant-UI框架实现购物车的复选框全选和反选功能

购物车页面的设计图商品的列表代码&#xff1a;v-for"(item,index) in shoppingListData.rows":key"index">:value"item.goods_id"v-model"item.isChecked"checked-color"#07c160"click"chooseChange(item.goods_id…

子窗口关闭后怎么把数据回传给主窗口。

Android开发系列六&#xff1a;子窗口向主窗口回传数据 2011-03-10 18:08假定主窗口Activity类为MainActivity&#xff0c;子窗口为ChildActivity&#xff0c;并假定closeButton是子窗口上的一个按钮&#xff0c;按这个按钮关闭子窗口并向主窗口回传数据。 首先在ChildActivity…

微软专家与您一起谈谈测试人员职业规划技术专家与您一起交流LoadRunner使用经验。...

<iframe align"top" marginwidth"0" marginheight"0" src"http://www.zealware.com/csdnblog01.html" frameborder"0" width"728" scrolling"no" height"90"></iframe>交流详细信…

iis mysql cpu_iis - 如何彻底优化php程序降低CPU占用?

运行环境IIS7.0 ISAPIPHP5.2.17MysqlZendOptimizer程序情况描述同一服务器环境下运行多套程序&#xff0c;程序是一套使用很长时间的老程序&#xff0c;现在在针对出现的问题优化&#xff0c;但是现在有一个严重的问题就是CPU占用高的情况亟待解决。程序是快速建站解决方案&…

Android用ImageView显示本地和网上的图片

ImageView是Android程序中经常用到的组件&#xff0c;它将一个图片显示到屏幕上。在UI xml定义一个ImageView如下&#xff1a;public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.myimage);ImageView image1 (Ima…

iOS 即时视频和聊天(基于环信)

先上效果图: 屏幕快照 2015-07-30 下午5.19.46.png说说需求:开发一个可以进行即时视频聊天软件. 最近比较忙,考完试回到公司就要做这个即时通信demo.本来是打算用xmpp协议来做视频通信的,想了想要搞后台,还要搭建服务器.一开始没明白是怎么样的一种形式.(现在想了想,其实就是自…

react native组件的生命周期

react native组件的生命周期 一、当页面第一次加载时&#xff0c;会依次调用&#xff1a; constructor() componentWillMount()&#xff1a; 这个函数调用时机是在组件创建&#xff0c;并初始化了状态之后&#xff0c;在第一次绘制 render() 之前。可以在这里做一些业务初始化操…