requestContentEditingInput(with:completionHandler:)
Requests asset information for beginning a content editing session.
Declaration
func requestContentEditingInput(with options: PHContentEditingInputRequestOptions?, completionHandler: @escaping (PHContentEditingInput?, [AnyHashable : Any]) -> Void) -> PHContentEditingInputRequestIDParameters
- 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.
Mentioned in
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.