In my application (written in Objective-C), how do I detect if the device is an iPhone, iPad, or iPhone5?
if([[UIDevice currentDevice]userInterfaceIdiom] ==
Here are a bunch of constants you can stick in your PCH file and use throughout your application which give you a lot of different things you can test for. (Widescreen here means iPhone 5 "taller" screen)
#ifndef IS_WIDESCREEN
#define IS_WIDESCREEN (fabs((double)[[UIScreen mainScreen] bounds].size.height - (double)568) < DBL_EPSILON)
#endif
#ifndef IS_IPHONE
#define IS_IPHONE ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"])
#endif
#ifndef IS_IPOD
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])
#endif
#ifndef IS_IPAD
#define IS_IPAD ([[[UIDevice currentDevice] model] isEqualToString:@"iPad"])
#endif
#ifndef IS_IPHONE5
#define IS_IPHONE5 (IS_WIDESCREEN && IS_IPHONE)
#endif
#ifndef IS_IPOD5
#define IS_IPOD5 (IS_WIDESCREEN && IS_IPOD)
#endif
You can use it like this:
if(IS_IPHONE5){
// load iPhone5 code/nibs
}
if(IS_WIDESCREEN){
// load 4" screen stuff here
}