---
title: "replaceAssets(at:withAssets:)"
framework: photos
role: symbol
role_heading: Instance Method
path: "photos/phassetcollectionchangerequest/replaceassets(at:withassets:)"
---

# replaceAssets(at:withAssets:)

Replaces the assets at the specified indexes in the asset collection with the specified assets.

## Declaration

```swift
func replaceAssets(at indexes: IndexSet, withAssets assets: any NSFastEnumeration)
```

## Parameters

- `indexes`: The indexes of the assets to be replaced in the asset collection.
- `assets`: An array of doc://com.apple.photokit/documentation/Photos/PHAsset objects to be inserted into (or moved within) the asset collection.

## Discussion

Discussion To ensure that the index set you specify is valid even if the asset collection has changed since you fetched it, create a change request with a snapshot of the asset collection’s contents using the init(for:assets:) method before rearranging assets. note: Assets from My Photo Stream or iCloud Shared Albums and assets synced to the device through iTunes cannot be added to collections. Transient asset collections (such as those created with the transientAssetCollection(with:title:) method) do not support adding or removing content.

## See Also

### Modifying Asset Collections

- [init(for:)](photos/phassetcollectionchangerequest/init(for:).md)
- [init(for:assets:)](photos/phassetcollectionchangerequest/init(for:assets:).md)
- [title](photos/phassetcollectionchangerequest/title.md)
- [addAssets(_:)](photos/phassetcollectionchangerequest/addassets(_:).md)
- [insertAssets(_:at:)](photos/phassetcollectionchangerequest/insertassets(_:at:).md)
- [removeAssets(_:)](photos/phassetcollectionchangerequest/removeassets(_:).md)
- [removeAssets(at:)](photos/phassetcollectionchangerequest/removeassets(at:).md)
- [moveAssets(at:to:)](photos/phassetcollectionchangerequest/moveassets(at:to:).md)
