Listing 2-1 Determining whether you’re compiling for a simulator
// Set hello to "Hello, <device or simulator>"!
|
#if TARGET_IPHONE_SIMULATOR
|
NSString *hello = @"Hello, iOS Simulator!";
|
#else
|
NSString *hello = @"Hello, iOS device!";
|
#endif
|
Listing 2-2 shows how to use the TARGET_OS_IPHONE macro in a source file to be shared between Mac OS X and iOS.
Listing 2-2 Determining whether you’re compiling for a device
#if TARGET_OS_IPHONE
|
#import <UIKit/UIKit.h>
|
#else
|
#import <Cocoa/Cocoa.h>
|
#endif
|
The TARGET_OS_IPHONE and TARGET_IPHONE_SIMULATOR macros are defined in the TargetConditionals.h header file.