0

I have the following pre-processor code to detect if the device is an iPhone or iPad, and I want to add iPhone5 to it:

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

#define POS_UI_CHEST  ( (IS_IPAD) ? (ccp(72.0,831.0)) : (ccp(33.0,396.0)) )
#define POS_UI_ROUTE  ( (IS_IPAD) ? (ccp(74.0,521.0)) : (ccp(36.0,240.0)) )
#define POS_UI_GUAGE  ( (IS_IPAD) ? (ccp(384.0,70.0)) : (ccp(160.0,20.0)) )
#define POS_UI_BALL   ( (IS_IPAD) ? (ccp(384.0,70.0)) : (ccp(160.0,20.0)) )

What would be the easiest way to add a 3rd ccp to each conditional?

Thanks!

DeviArt
  • 469
  • 1
  • 5
  • 11

1 Answers1

1

You can nest ? : operators as such:

#define POS_UI_CHEST ( IS_IPAD ? ccp(72.0,831.0) : (IS_IPHONE5 ? ccp(xxx.0,yyy.0) : ccp(33.0,396.0)) )

(I removed the (unnecessary (brackets (for)) ((clarity)) )

You can find macros for iPhone 5 detection on stackoverflow.

Community
  • 1
  • 1
CodeSmile
  • 64,284
  • 20
  • 132
  • 217