Instance Method

performChangesAndWait(_:)

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

Declaration

func performChangesAndWait(_ changeBlock: @escaping () -> Void) throws

Parameters

changeBlock

A block that requests changes to be performed.

This block takes no parameters and has no return value.

error

If an error occurs, this pointer is set to an NSError object describing the error. If you do not want error information, pass in nil.

Return Value

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

Discussion

Do not call this method from the main thread. Your change block, and the work that Photos performs on your behalf to apply the changes it requests, take some time to execute. (Photos may need to prompt the user to perform changes, so this method can block execution indefinitely.) Use this method if you are already performing work on a background queue that results in a change to be applied to the Photos library. To request changes from the main queue, use the performChanges(_:completionHandler:) method instead.

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 performChanges(() -> Void, completionHandler: ((Bool, Error?) -> Void)?)

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