tags:

views:

503

answers:

2

Hi, I would like to check if the user is using an iPhone 4 or not. How can I do that ?

Thanks ! Sebastian

A: 

To detect the difference between the iPod Touch and the iPhone, we use

if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 

There might be something similar to check for a the forward camera.

Andy
+1. Checking for the forward-facing camera is a decent option to determine if the hardware is iPhone 4+. Indeed it will eval to true when another device has a front camera as well - iPad or iPod Touch.
p.campbell
+10  A: 

Apple specifically recommends against this, instead preferring that you check for individual features and act according to these. This makes your life a lot easier when Apple releases new hardware; if for instance Apple releases an iPod Touch with a camera, and you need a camera for your app, your users wont be upset that it tells them "No camera found" when it does have one, all because it reports as not an iPhone. Here is one way to require all the differentiating hardware features. Do not use these for enabling/disabling features that are supported but not required: this can be determined at runtime through the APIs used to interact with that feature.

UIDevice (see here, also the docs) can help you determine if it is an iPhone, but again, don't do this.

Jared P
+1 this is the best advice
Dave DeLong