Instance Method

performChanges(_:completionHandler:)

Asynchronously runs a block that requests changes to be performed in the photo library.

Declaration

func performChanges(_ changeBlock: @escaping () -> Void, completionHandler: ((Bool, Error?) -> Void)? = nil)

Parameters

changeBlock

A block that requests changes to be performed.

This block takes no parameters and has no return value.

completionHandler

A block that Photos calls after the change block completes and Photos performs the requested changes.

The block takes the following parameters:

success

true if Photos successfully applied the changes requested in the block; otherwise, false.

error

If an error occurs, an NSError object describing the error; otherwise, nil.

Discussion

Photos executes both the change block and the completion handler block on an arbitrary serial queue. To update your app’s UI as a result of a change, dispatch that work to the main queue.

See Also

Applying Changes to the Photo Library

Requesting Changes to the Photo Library

Create, delete, or modify assets and collections in a photo library by making change requests.

func performChangesAndWait(() -> Void)

Synchronously runs a block that requests changes to be performed in the photo library.

class PHAssetChangeRequest

A request to create, delete, change metadata for, or edit the content of a Photos asset, for use in a photo library change block.

class PHAssetCollectionChangeRequest

A request to create, delete, or modify a Photos asset collection, for use in a photo library change block.

class PHCollectionListChangeRequest

A request to create, delete, or modify a Photos collection list, for use in a photo library change block.

class PHObjectPlaceholder

A read-only proxy representing a Photos asset or collection object yet to be created by a change request.