Kev*_*tre 58 iphone cocoa-touch
使用TARGET_IPHONE_SIMULATOR宏会导致在am应用程序中定义相同的常量值.例如:
#ifdef TARGET_IPHONE_SIMULATOR
NSString * const Mode = @"Simulator";
#else
NSString * const Mode = @"Device";
#endif
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
...
NSLog(@"Mode: %@", Mode);
...
}
Run Code Online (Sandbox Code Playgroud)
始终导致记录"模式:模拟器".我正在运行XCode 3.2.4,如果这有帮助的话.谢谢.
Kev*_*tre 106
TARGET_OS_SIMULATOR在设备上定义(但定义为false).修复是:
#include <TargetConditionals.h> // required in Xcode 8+
#if TARGET_OS_SIMULATOR
NSString * const Mode = @"Simulator";
#else
NSString * const Mode = @"Device";
#endif
Run Code Online (Sandbox Code Playgroud)
不知道什么时候改变了.我很确定过去可以使用'ifdef'.
Seb*_*ian 13
对我来说明确包括TargetConditionals.h帮助
#include <TargetConditionals.h>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20957 次 |
| 最近记录: |