Instance Method

requestContentEditingInput(with:completionHandler:)

Requests asset information for beginning a content editing session.

Declaration

func requestContentEditingInput(with options: PHContentEditingInputRequestOptions?, completionHandler: @escaping (PHContentEditingInput?, [AnyHashable : Any]) -> Void) -> PHContentEditingInputRequestID

Parameters

options

Options affecting how Photos handles an edit session request.

completionHandler

A block that Photos calls when the requested asset editing information is ready.

The block takes the following parameters:

contentEditingInput

An object that describes the asset for editing and provides methods for loading the image or video content to be edited.

info

A dictionary providing information about the status of the request. See Editing Request Info Keys for possible keys and values.

In iOS 10.0, tvOS 10.0, and later, Photos always calls this block on the main queue. In earlier releases, Photos calls this block on an arbitrary serial queue—if your block needs to update the UI, dispatch that work to the main queue.

Return Value

A numeric identifier for the request. Pass this identifier to the cancelContentEditingInputRequest(_:) method if you need to cancel the request before it completes.

Discussion

When you call this method, Photos downloads the asset’s image or video data (if necessary) and prepares it for editing, then calls your completionHandler block to provide a PHContentEditingInput object you use for editing.

To complete the edit, create a PHContentEditingOutput object from the editing input to provide the edited asset data. Then, commit the edit by posting a change block to the shared PHPhotoLibrary object. In the block, create a PHAssetChangeRequest object and set its contentEditingOutput property to the editing output you created.

See Also

Editing an Asset

Editing Asset Content

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

class PHContentEditingInput

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

class PHContentEditingOutput

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

class 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.

class PHContentEditingInputRequestOptions

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

class PHLivePhotoEditingContext

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

protocol PHLivePhotoFrame

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

func canPerform(PHAssetEditOperation) -> Bool

Returns whether the asset supports the specified editing operation.

enum PHAssetEditOperation

Values identifying possible actions an asset can support, used by the canPerform(_:) method.

func cancelContentEditingInputRequest(PHContentEditingInputRequestID)

Cancels a request for editing the asset’s content.

typealias 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 requestContentEditingInput(with:completionHandler:) method.

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