---
title: "replaceChildCollections(at:withChildCollections:)"
framework: photos
role: symbol
role_heading: Instance Method
path: "photos/phcollectionlistchangerequest/replacechildcollections(at:withchildcollections:)"
---

# replaceChildCollections(at:withChildCollections:)

Replaces the child collections at the specified indexes in the collection list with the specified collections.

## Declaration

```swift
func replaceChildCollections(at indexes: IndexSet, withChildCollections collections: any NSFastEnumeration)
```

## Parameters

- `indexes`: The indexes of the child collections to be replaced in the collection list.
- `collections`: An array of doc://com.apple.photokit/documentation/Photos/PHCollection objects (asset collections or other collection lists) to be inserted into (or moved within) the collection list.

## Discussion

Discussion To ensure that the index set you specify is valid even if the collection list has changed since you fetched it, create a change request with a snapshot of the collection list’s contents using the init(for:childCollections:) method before rearranging child collections.

## See Also

### Managing Collections

- [addChildCollections(_:)](photos/phcollectionlistchangerequest/addchildcollections(_:).md)
- [insertChildCollections(_:at:)](photos/phcollectionlistchangerequest/insertchildcollections(_:at:).md)
- [moveChildCollections(at:to:)](photos/phcollectionlistchangerequest/movechildcollections(at:to:).md)
- [removeChildCollections(_:)](photos/phcollectionlistchangerequest/removechildcollections(_:).md)
- [removeChildCollections(at:)](photos/phcollectionlistchangerequest/removechildcollections(at:).md)
