Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#if check (preprocessor macro) to differentiate between iPhone and iPad

Is there a build preprocessor macro I can check, with #if or #ifdef to determine if my current Xcode project is being built for iPhone or iPad?

EDIT

As several answers have pointed out, often apps are universal, and the same binary can run on both devices. Conditional behavior between these very similar devices should be solved at runtime rather than compile time.

like image 700
Justin Meiners Avatar asked Sep 12 '10 23:09

Justin Meiners


1 Answers

Some ideas in the comment section of this blog

http://greensopinion.blogspot.com/2010/04/from-iphone-to-ipad-creating-universal.html

Mostly using

UI_USER_INTERFACE_IDIOM()

Such as:

#ifdef UI_USER_INTERFACE_IDIOM()
  #define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#else
  #define IS_IPAD() (false)
#endif
like image 194
Lou Franco Avatar answered Oct 04 '22 04:10

Lou Franco