finishContentEditing(completionHandler:)
finishContentEditing(completionHandler:)
finishContentEditing(completionHandler:) Instance Method of PHContentEditingController Asks your extension for edited asset data to finish the editing session.
func finishContentEditing(completionHandler: @escaping (PHContentEditingOutput?) -> Void)Parameters
completionHandler
A block for your extension to call when you have finished editing.
The block takes the following parameter: - term output: The `doc://com.apple.photokit/documentation/Photos/PHContentEditingOutput` object you created and populated before calling the completion handler.
Discussion
Photos calls this method when the user chooses to end the editing session. Your extension view controller should:
- Disable UI elements to prevent the user from editing further while you complete the remaining steps on a background queue.
- Create a `
doc://com.apple.photokit/documentation/Photos/PHContentEditingOutputobject from thedoc://com.apple.photokit/documentation/Photos/PHContentEditingInputobject that Photos provided to your extension in thedoc://com.apple.photokit/documentation/PhotosUI/PHContentEditingController/startContentEditing(with:placeholderImage:)` method.
Use the content editing output to store the rendered photo or video data from the user’s edits and a PHAdjustmentData object describing the edits.
Note: To end editing without committing changes to the asset, leave the content editing output’s `
doc://com.apple.photokit/documentation/Photos/PHContentEditingOutput/adjustmentDataproperty set toniland do not write to the location specified by itsdoc://com.apple.photokit/documentation/Photos/PHContentEditingOutput/renderedContentURL` property.
- Call the
completionHandlerblock with your content editing output, to notify Photos that the edit is complete. - After the
completionHandlerblock finishes executing, you may safely clean up any data or files related to your edit.