Is there a specific Xcode compiler flag that gets set when compiling for iPad?

ipad, iphone-sdk-3.2

Solution

The correct API to use for run-time checking of iPad vs. iPhone/iPad Touch is:

BOOL deviceIsPad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);

The UIDevice header filer also includes a convenient macro, UI_USER_INTERFACE_IDIOM(), which will be helpful if your deployment target is < iPhone 3.2.

#define UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)

So you could just say, negatively:

BOOL deviceIsPad = (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone);

Problem

Is there a specific Xcode compiler flag that gets set when compiling for iPad? I want to conditionally compile iPad vs iPhone/iPod Touch code for example: ``` #ifdef TARGET_IPAD code for iPad #else code for iPhone #endif ``` I know there is already TARGET_OS_IPHONE and TARGET_CPU_ARM in TargetConditionals.h but anything that easily and specifically targets iPad? -Rei

Original source