views:

79

answers:

1

Hello

I declare some constants in a header file which need to be different depending on whether it is an iPad or an iPhone app. How would I do this?

i.e

#ifdef ISIPAD
static NSString myconst = @"ipad!";
#else
static NSString myconst = @"iphone!";
#endif
+2  A: 

If you're writing an universal app, you can't do a compile time check since the compiler generates one executable for both the iPhone and the iPad. If you've got separate apps for iPhone and iPad (with a shared codebase), why not just #define ISIPAD appropriately yourself. Otherwise, you have to do a check at runtime.

You could make them global variables that get initialized when your app starts up by checking to see which device you're running on then setting them appropriately.

Andrew Madsen