<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PhotoKit",
  "identifier" : "/documentation/Photos/PHPhotoLibrary/performChangesAndWait(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Photos"
    ],
    "preciseIdentifier" : "c:objc(cs)PHPhotoLibrary(im)performChangesAndWait:error:"
  },
  "title" : "performChangesAndWait(_:)"
}
-->

# performChangesAndWait(_:)

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

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

## 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:)`](/documentation/Photos/PHPhotoLibrary/performChanges(_:completionHandler:)) method instead.

> Note:
> For each call to this method, iOS shows an alert asking the user for permission to edit the contents of the photo library. If your app needs to submit several changes at once, combine them into a single change block. For example, to edit the content of multiple existing photos, create multiple ``doc://com.apple.photokit/documentation/Photos/PHAssetChangeRequest`` objects and set the ``doc://com.apple.photokit/documentation/Photos/PHAssetChangeRequest/contentEditingOutput`` property on each to an independent ``doc://com.apple.photokit/documentation/Photos/PHContentEditingOutput`` object.

> Handling Errors in Swift:
> In Swift, this method returns `Void` and is marked with the `throws` keyword to indicate that it throws an error in cases of failure.
> 
> You call this method in a `try` expression and handle any errors in the `catch` clauses of a `do` statement, as described in [Error Handling](https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html) in [The Swift Programming Language](https://docs.swift.org/swift-book/) and `About Imported Cocoa Error Parameters`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)