<!--
{
  "documentType" : "article",
  "framework" : "PhotoKit",
  "identifier" : "/documentation/PhotoKit/requesting-changes-to-the-photo-library",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Requesting 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.

## Discussion

Because [`PHAsset`](/documentation/Photos/PHAsset), [`PHAssetCollection`](/documentation/Photos/PHAssetCollection), and [`PHCollectionList`](/documentation/Photos/PHCollectionList) instances are immutable objects, you can’t make changes to them. To modify the Photos assets or collections these objects represent, use the shared photo library to execute a change block. Inside the change block, create change request objects. Then apply a change block with one of the methods listed in Updating the Library. The changes you request take effect after Photos runs the change block and calls your completion handler.

Each of the change request classes—[`PHAssetChangeRequest`](/documentation/Photos/PHAssetChangeRequest), [`PHAssetCollectionChangeRequest`](/documentation/Photos/PHAssetCollectionChangeRequest), and [`PHCollectionListChangeRequest`](/documentation/Photos/PHCollectionListChangeRequest)—corresponds to an asset or collection class. Use these classes to make the following types of changes:

Creating items. Each change request class provides methods for requesting to create a new item of the corresponding asset or collection class. For example, use the [`creationRequestForAssetCollection(withTitle:)`](/documentation/Photos/PHAssetCollectionChangeRequest/creationRequestForAssetCollection(withTitle:)) method to create an asset collection.

To reference a newly created request within the change block—for example, to add a new asset to a collection—use the [`PHObjectPlaceholder`](/documentation/Photos/PHObjectPlaceholder) object provided by the change request. After the change block completes, use the placeholder object’s [`localIdentifier`](/documentation/Photos/PHObject/localIdentifier) property to fetch the created object.

Deleting items. Each change request class provides methods for requesting to delete one or more items of the corresponding asset or collection class. For example, use the [`deleteCollectionLists(_:)`](/documentation/Photos/PHCollectionListChangeRequest/deleteCollectionLists(_:)) method to delete collection lists.

Modifying items. You modify an existing asset or collection by creating a change request from a [`PHAsset`](/documentation/Photos/PHAsset), [`PHAssetCollection`](/documentation/Photos/PHAssetCollection), or [`PHCollectionList`](/documentation/Photos/PHCollectionList) object representing it. For example, the [`init(for:)`](/documentation/Photos/PHAssetChangeRequest/init(for:)) method creates a change request you can use for modifying an asset.

After creating a change request, use its properties and instance methods to modify the corresponding features of the asset or collection it represents. For example, to set an asset’s [`isFavorite`](/documentation/Photos/PHAsset/isFavorite) property, set the [`isFavorite`](/documentation/Photos/PHAssetChangeRequest/isFavorite) property of a change request created from that asset. To add to an asset collection, call the [`addAssets(_:)`](/documentation/Photos/PHAssetCollectionChangeRequest/addAssets(_:)) method on an asset collection change request.

### Create an Asset for an Album

Use a change block to combine several changes to the photo library into a single atomic update. The following code uses a change block to create an asset from an image and add that asset to an album.

```swift
func addAsset(image: UIImage, to album: PHAssetCollection) {
    PHPhotoLibrary.shared().performChanges {
        // Request creating an asset from the image.
        let creationRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
        // Request editing the album.
        guard let addAssetRequest = PHAssetCollectionChangeRequest(for: album) else { return }
        // Get a placeholder for the new asset and add it to the album editing request.
        addAssetRequest.addAssets([creationRequest.placeholderForCreatedAsset!] as NSArray)
    } completionHandler: { success, error in
        if !success, let error = error {
            print("error creating asset: \(error)")
        }
    }
}
```

For each call to the [`performChanges(_:completionHandler:)`](/documentation/Photos/PHPhotoLibrary/performChanges(_:completionHandler:)) or [`performChangesAndWait(_:)`](/documentation/Photos/PHPhotoLibrary/performChangesAndWait(_:)) method, Photos 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 add several new images in one batch, extend the code to create multiple [`PHAssetChangeRequest`](/documentation/Photos/PHAssetChangeRequest) objects using the [`creationRequestForAsset(from:)`](/documentation/Photos/PHAssetChangeRequest/creationRequestForAsset(from:)) method. To edit the content of multiple existing photos, create multiple [`PHAssetChangeRequest`](/documentation/Photos/PHAssetChangeRequest) objects and set the [`contentEditingOutput`](/documentation/Photos/PHAssetChangeRequest/contentEditingOutput) property on each to an independent [`PHContentEditingOutput`](/documentation/Photos/PHContentEditingOutput) object.

You can modify and delete assets in a similar way.

---

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)