BQu*_*dra 0 objective-c xcode4
如果我的程序在模拟器o设备上运行,我如何用常量检查XCode 4?像这样的东西:
#ifdef RUNING_ON_DEVICE
#else
#endif
Run Code Online (Sandbox Code Playgroud)
有几种选择
预处理器宏:
#if TARGET_IPHONE_SIMULATOR
//is sim
#elif TARGET_OS_IPHONE
//is real device
#else
//unknown target
#endif
Run Code Online (Sandbox Code Playgroud)
或者,如果您宁愿以某种方式执行此操作:
if ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone Simulator"]) {
//device is simulator
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
809 次 |
| 最近记录: |