以编程方式检测app是否正在设备或模拟器上运行 [英] Programmatically detect if app is being run on device or simulator

查看:242
本文介绍了以编程方式检测app是否正在设备或模拟器上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我的应用程序是否在运行时在设备或模拟器上运行。有没有办法检测到这个?

I'd like to know whether my app is being run on device or simulator at run time. Is there a way to detect this?

原因是用模拟器测试蓝牙api:
http://volcore.limbicsoft.com/2009/09/iphone-os-31-gamekit-pt -1-woooohooo.html

Reason being to test bluetooth api with simulator: http://volcore.limbicsoft.com/2009/09/iphone-os-31-gamekit-pt-1-woooohooo.html

推荐答案

#if TARGET_OS_SIMULATOR

//Simulator

#else

// Device

#endif

请参考此前的SO问题在为iPhone编译时,Xcode设置了哪些#defines

Pls refer this previous SO question also What #defines are set up by Xcode when compiling for iPhone

这篇关于以编程方式检测app是否正在设备或模拟器上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆