Fetching Assets

Fetching Assets

Fetching Assets Retrieve asset metadata or request full asset content.

Overview

You fetch assets to begin working with them. Use the class methods listed in Fetching Assets to retrieve one or more PHAsset instances representing the assets you want to display or edit. For example, to fetch all the assets in an asset collection (such as an album or moment), use the fetchAssets(in:options:)) method. Each fetch method takes a PHFetchOptions parameter that you use to specify the assets to retrieve and how to sort them.

Important Accessing or modifying the Photos library requires explicit authorization from the user. The first time you call one of the methods listed in Fetching Assets, Photos automatically prompts the user for authorization. Alternatively, you can use the PHPhotoLibrary requestAuthorization(:)) method to prompt the user at a time of your choosing. For more information, see Requesting Authorization to Access Photos.