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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.