Recipe: Snapping Photos

In addition to selecting pictures, the image picker controller enables you to snap photos with a device’s built-in camera. Because cameras are not available on all iOS units (specifically, older iPod touch and iPad devices), begin by checking whether the device running the application supports camera usage:

if ([UIImagePickerController isSourceTypeAvailable:     UIImagePickerControllerSourceTypeCamera]) ...

The rule is this: Never offer camera-based features for devices that don’t have cameras. Although iOS 7 was deployed only to camera-ready devices, no one but Apple knows what hardware will be released in the future. As unlikely as it sounds, Apple could introduce new models without cameras. ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.