Class

PHAsset

A representation of an image, video, or Live Photo in the Photos library.

Declaration

@interface PHAsset : PHObject

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.

Assets contain only metadata. The underlying image or video data for any given asset might not be stored on the local device. However, depending on how you plan to use this data, you may not need to download all of it. If you need to populate a collection view with thumbnail images, the Photos framework can manage downloading, generating, and caching thumbnails for each asset. For details, see PHImageManager.

Asset objects are immutable. To edit an asset’s metadata (such as marking it as a favorite photo), create a PHAssetChangeRequest object within a photo library change block. For more details on using change requests and change blocks to update the photo library, see PHPhotoLibrary.

Topics

Fetching Assets

Fetching Assets

Retrieve asset metadata or request full asset content.

+ fetchAssetsInAssetCollection:options:

Retrieves assets from the specified asset collection.

+ fetchAssetsWithMediaType:options:

Retrieves assets with the specified media type.

+ fetchAssetsWithLocalIdentifiers:options:

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

+ fetchKeyAssetsInAssetCollection:options:

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

+ fetchAssetsWithOptions:

Retrieves all assets matching the specified options.

+ fetchAssetsWithBurstIdentifier:options:

Retrieves assets with the specified burst photo sequence identifier.

+ fetchAssetsWithALAssetURLs:options:

Retrieves assets using URLs provided by the Assets Library framework.

Deprecated

Reading Asset Metadata

mediaType

The type of the asset, such as video or audio.

PHAssetMediaType

Constants identifying the general type of an asset, such as image or video.

mediaSubtypes

The subtypes of the asset, identifying special kinds of assets such as panoramic photo or high-framerate video.

PHAssetMediaSubtype

Constants identifying specific variations of asset media, such as panorama or screenshot photos and time lapse or high frame rate video.

sourceType

The means by which the asset entered the user’s Photos library.

PHAssetSourceType

Means by which an asset enters the Photos library, used by the PHAssetSourceType property.

pixelWidth

The width, in pixels, of the asset’s image or video data.

pixelHeight

The height, in pixels, of the asset’s image or video data.

creationDate

The date and time at which the asset was originally created.

modificationDate

The date and time at which the asset was last modified.

location

The location information saved with the asset.

duration

The duration, in seconds, of the video asset.

favorite

A Boolean value that indicates whether the user has marked the asset as a favorite.

hidden

A Boolean value that indicates whether the user has hidden the asset.

syncFailureHidden

A Boolean value that indicates whether the user has chosen to hide to the sync failure message.

Deprecated

Displaying an Asset

playbackStyle

An enumerated value that describes how to present an asset to the user.

PHAssetPlaybackStyle

An enumeration of asset playback styles that dictate how to present an asset to the user.

Editing an Asset

Editing Asset Content

Make a request to modify and save a photo or video asset.

PHContentEditingInput

A container that provides information about and access to the image, video, or Live Photo content of an asset to be edited.

PHContentEditingOutput

A container to which you provide the results of editing the photo, video, or Live Photo content of a Photos asset.

PHAdjustmentData

A description of the edits made to an asset's photo, video, or Live Photo content, which allows your app to reconstruct or revert the effects of prior editing sessions.

PHContentEditingInputRequestOptions

A set of options affecting the delivery of image or video data when you request to edit the content of a Photos asset.

PHLivePhotoEditingContext

An editing session for modifying the photo, video, and audio content of a Live Photo.

PHLivePhotoFrame

A container that provides image content for a single frame of a Live Photo in an editing context.

- canPerformEditOperation:

Returns whether the asset supports the specified editing operation.

PHAssetEditOperation

Values identifying possible actions an asset can support, used by the canPerformEditOperation: method.

- requestContentEditingInputWithOptions:completionHandler:

Requests asset information for beginning a content editing session.

- cancelContentEditingInputRequest:

Cancels a request for editing the asset’s content.

PHContentEditingInputRequestID

An identifier for an asset content editing session.

Editing Request Info Keys

Keys indicating the status of an asset content editing request, used in the completion handler of the requestContentEditingInputWithOptions:completionHandler: method.

Working with Burst Photo Assets

burstIdentifier

The unique identifier shared by photo assets from the same burst sequence.

burstSelectionTypes

The selection type of the asset in a burst photo sequence.

PHAssetBurstSelectionType

Bit mask values indicating whether and how an asset is marked as a favorite member of a burst photo sequence. Used by the burstSelectionTypes property.

representsBurst

A Boolean value that indicates whether the asset is the representative photo from a burst photo sequence.

Relationships

Inherits From

See Also

Asset Retrieval

Fetching Objects and Requesting Changes

Get assets, asset collections, and collection lists matching a specified query.

PHAssetCollection

A representation of a Photos asset grouping, such as a moment, user-created album, or smart album.

PHCollection

The abstract superclass for Photos asset collections and collection lists.

PHCollectionList

A group containing Photos asset collections, such as Moments, Years, or folders of user-created albums.

PHObject

The abstract superclass for Photos model objects (assets and collections).

PHFetchResult

An ordered list of assets or collections returned from a Photos fetch method.

PHFetchOptions

A set of options that affect the filtering, sorting, and management of results that Photos returns when you fetch asset or collection objects.