Type Method

fetchAssets(with:options:)

Retrieves assets with the specified media type.

Declaration

class func fetchAssets(with mediaType: PHAssetMediaType, options: PHFetchOptions?) -> PHFetchResult<PHAsset>

Parameters

mediaType

A media type, such as image or video. See PHAssetMediaType.

options

Options that specify a filter predicate and sort order for the fetched assets, or nil to use default options. For details, see PHFetchOptions.

Return Value

A fetch result that contains the requested PHAsset objects, or an empty fetch result if no objects match the request.

Discussion

By default, the returned PHFetchResult object contains all assets with the specified type. To retrieve a more specific set of assets, provide a PHFetchOptions object containing a filter predicate.

By default, fetch results do not include photos synced to the device through iTunes or stored in iCloud Shared Albums. To change this behavior, use the includeAssetSourceTypes property in the options parameter.

See Also

Fetching Assets

Fetching Assets

Retrieve asset metadata or request full asset content.

class func fetchAssets(withLocalIdentifiers: [String], options: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves assets with the specified local-device-specific unique identifiers.

class func fetchKeyAssets(in: PHAssetCollection, options: PHFetchOptions?) -> PHFetchResult<PHAsset>?

Retrieves assets marked as key assets in the specified asset collection.

class func fetchAssets(with: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves all assets matching the specified options.

class func fetchAssets(withALAssetURLs: [URL], options: PHFetchOptions?) -> PHFetchResult<PHAsset>

Retrieves assets using URLs provided by the Assets Library framework.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software