The photos and videos accessed by the user through the Photos app constitute the device’s photo library. Your app can give the user an interface for exploring this library through the UIImagePickerController class.
In addition, the Photos framework lets you access the photo library and its contents programmatically — including the ability to modify a photo’s image. You’ll need to
The UIImagePickerController class can also be used to give the user an interface similar to the Camera app, letting the user take photos and videos on devices with the necessary hardware. At a deeper level, the AV Foundation framework (Chapter 15) provides direct control over the camera hardware. You’ll need to
import AVFoundation (and probably
Constants such as
kUTTypeImage, referred to in this chapter, are provided by the Mobile Core Services framework; you’ll need to
Access to the photo library requires user authorization. You can use UIImagePickerController without prior authorization, as authorization will be requested for you automatically and the interface works coherently if authorization has been refused. Nevertheless, it is probably good policy for any app that’s going to need photo library access to ascertain authorization status at launch time, and to try to obtain authorization if needed. My strategy is to check the authorization status every time the root view controller ...