2

Possible Duplicate:
Determine device (iPhone, iPod Touch) with iPhone SDK
How to find iPhone/iPod Device model(3G,3GS,4,4S) by code?

I know there is a way to get the model and localized model of the phone by using the command [[UIDevice currentDevice] model] or [[UIDevice currentDevice] localizedModel], but on several iPhones, both commands generate the same result, which is "iPhone" (or "iPad" for all iPads).

I was hoping to find a way to detect whether the device is an iPhone 3, 3S, 4, 4S, or 5 (or iPad 1, 2, etc). Is this value hidden within the uniqueIdentifier, or is there an easier way to find this?

Community
  • 1
  • 1
Robert
  • 112
  • 2
  • 13
  • Discussed on: http://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-iphone-sdk – Ali Seymen Jan 22 '13 at 22:04
  • Duplicate of [Determine device (iPhone, iPod Touch) with iPhone SDK](http://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-iphone-sdk) and [Detect the specific iPhone/iPod touch model](http://stackoverflow.com/questions/1108859/detect-the-specific-iphone-ipod-touch-model) – iDev Jan 22 '13 at 22:08
  • And as noted in the answers to those duplicate questions, you shouldn't do this. – rickster Jan 23 '13 at 04:49

1 Answers1

1

From this iphonedevsdk post,

#import <sys/utsname.h>

struct utsname u;
uname(&u);

NSString *nameString =  [NSString stringWithCString:u.machine encoding:NSUTF8StringEncoding];    

Check this blog "iPhone @2x Graphics, scale, and iPad" and this list of identifiers as well.

iDev
  • 23,310
  • 7
  • 60
  • 85