PHAsset
A representation of an image, video, or Live Photo in the Photos library.
Declaration
class PHAssetMentioned in
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 AssetsfetchAssets(in:options:)fetchAssets(with:options:)fetchAssets(withLocalIdentifiers:options:)fetchKeyAssets(in:options:)fetchAssets(with:)fetchAssets(withBurstIdentifier:options:)fetchAssets(withALAssetURLs:options:)
Reading Asset Metadata
contentTypemediaTypePHAssetMediaTypemediaSubtypesPHAssetMediaSubtypesourceTypePHAssetSourceTypepixelWidthpixelHeightaddedDatecreationDatemodificationDatelocationdurationisFavoriteisHiddenhasAdjustmentsadjustmentFormatIdentifierisSyncFailureHidden
Displaying an Asset
Editing an Asset
Editing Asset ContentPHContentEditingInputPHContentEditingOutputPHAdjustmentDataPHContentEditingInputRequestOptionsPHLivePhotoEditingContextPHLivePhotoFramecanPerform(_:)PHAssetEditOperationrequestContentEditingInput(with:completionHandler:)cancelContentEditingInputRequest(_:)PHContentEditingInputRequestIDEditing Request Info Keys