Please consider subscribing to Mobile Developer Tips RSS feed or following us on Twitter
|
|
|
If you ever need to know whether your application is running on an iPod touch or an iPhone, the answer is as close as this one line of code:
NSString *deviceType = [UIDevice currentDevice].model;
To get the model of the device as a localized string:
NSString *deviceType = [UIDevice currentDevice].modellocalizedModel;
NSLog(@"type: %@", deviceType);
One use could be to customize messages shown within your applications, for example:
float version = 1.1;
...
NSString *deviceType = [UIDevice currentDevice].model;
NSLog(@"Your %@ has version %2.1f of Today's Horoscope installed.",
deviceType, version);
Here’s the output from both of the code snippets is shown below:

Related posts:
- Where Was Touch – Determine if Touch/Point is Within Rectangle
- Getting the iPhone User Name
- Launching Other Apps within an iPhone Application
Comments
One Response to “Is Application Running on iPhone or iPod touch”
Leave Comment
Have you figured out how to get which version of the iPhone returned i.e 3g or 3GS? [UIDevice currentDevice] doesn’t seem to store that information.
[Reply]