Search code examples
iphonecocoa-touchiphone-sdk-3.0ios4iphone-4

Determine the hardware for iPhone


How can I tell if the application is running on iPhone 4 or iPhone 3GS or an iPad?

I want to determine if which hardware I'm using and then provide additional functionality if it's an iPhone 4 (such as using the video light or gyro-sensor).

Any help would greatly be appreciated.

Thanks

PS: I'm looking to determine this programmatically and not determine if based on physical appearance.


Solution

  • RE: sample code to detect if a flash is available

       for (AVCaptureDevice *cameraDevice in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
            if ([cameraDevice hasFlash]) {
                NSLog(@" Yay! A flash!"):
            }
        }
    

    But seriously, dude, Vladimir gave you the class name and the method name. If you had opened the documentation, you'd have had figured it out in a jiffy - certainly quicker than waiting on someone to paste you five lines of code.