Is it necessary to check if camera exists when targeting iOS 6+?
avfoundation, camera, ios, ios6
Solution
From the docs for the `UIImagePickerController isSourceTypeAvailable:` method:
Because a media source may not be present or may be unavailable, devices may not always support all source types. For example, if you attempt to pick an image from the user’s library and the library is empty, this method returns NO. Similarly, if the camera is already in use, this method returns NO.
Before attempting to use an UIImagePickerController object to pick an image, you must call this method to ensure that the desired source type is available.
So yes Apple does tell you to check. Besides, how hard is it to do:
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
// show camera
} else {
// don't show camera
}
Problem
I am making an app that makes use of the camera in multiple areas and it came upon me that all devices that support iOS 6+ have a camera. This is more of a programming practice question than a practical implementation question. Apple never explicitly recommends that you have to check for a camera, but many developers do. Is it safe to not check? What are the implications of NOT checking for a camera? Is there any performance advantage/disadvantage? Thanks, Virindh Borra