Possible Duplicate:
Best way to programmatically detect iPad/iPhone hardware
How can I differentiate the iPad and iPhone programmatically?
Possible Duplicate:
Best way to programmatically detect iPad/iPhone hardware
How can I differentiate the iPad and iPhone programmatically?
It seems for me that the question is a duplicate, but I'll try to brief all I know about device type and iOS version detection.
There are several methods based on which information you want to receive, whether it just device type (iPhone, iPod or iPad) or iOS version.
Here is code for detecting device type (returns i386 in case of Simulator):
#import <sys/utsname.h>
+ (NSString *)getDeviceType {
struct utsname systemInfo;
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8Encoding];
}
And here is iOS version detector:
+ (float)getOSVersion {
return [[[UIDevice currentDevice] systemVersion] floatValue];
}
And OS detector for compiler:
#ifdef __IPHONE_4_0
//this part of code will be running on devices with os iOS4+
#else
//this part of code will be running on devices with os _UNDER_ iOS4+
#endif
Also, nobody proibits us to use
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED > 40000
//this part of code will be running on devices with os iOS4+
#endif