views:

69

answers:

1

Hi, I want to programmatically differentiate between iPhone4 and iTouch4. Here is what I have tried :

+(BOOL) isIphone4 {
     if ( ![ImagePicker isIpodTouch4] ) {
          return NO;
     }

     if ([UIImagePickerController respondsToSelector:@selector(isFlashAvailableForCameraDevice:)]) {
          if ([UIImagePickerController isFlashAvailableForCameraDevice:UIImagePickerControllerCameraDeviceRear]) {
               return YES;
          }
     }
     return NO;
}

+(BOOL) isIpodTouch4 {
     if ([UIImagePickerController respondsToSelector:@selector(isCameraDeviceAvailable:)] ) {
          if ([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
               return YES;
          }
     }
     return NO;
}

However, seems like iPod Touch 4 is also passing the test for iPhone4. Does anyone have any ideas?

Thanks.

+1  A: 

This is similar:

http://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-iphone-sdk

The code example included allows you to tell the exact device.

Ben