使用宏TARGET_IPHONE_SIMULATOR
導致在應用程序中定義相同的常量值。例如:目標iPhone模擬器宏不工作
#ifdef TARGET_IPHONE_SIMULATOR
NSString * const Mode = @"Simulator";
#else
NSString * const Mode = @"Device";
#endif
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
...
NSLog(@"Mode: %@", Mode);
...
}
始終導致記錄「模式:模擬器」。如果有幫助,我目前正在運行XCode 3.2.4。謝謝。
ifdef更改爲if – Taranfx 2011-03-07 07:06:44
TARGET_IPHONE_SIMUATOR有一個拼寫錯誤(缺少'L'),並且它顯示在谷歌搜索預覽中。 – wilsonmichaelpatrick 2017-07-21 19:05:25
@wilsonmichaelpatrick固定 – 2017-07-21 19:49:03