---
title: "moveAssets(at:to:)"
framework: photos
role: symbol
role_heading: Instance Method
path: "photos/phassetcollectionchangerequest/moveassets(at:to:)"
---

# moveAssets(at:to:)

Moves the assets at the specified indexes in the asset collection to a new index.

## Declaration

```swift
func moveAssets(at fromIndexes: IndexSet, to toIndex: Int)
```

## Parameters

- `fromIndexes`: The indexes of the assets to be moved in the asset collection.
- `toIndex`: The index at which to place the moved assets, relative to the collection’s ordering after removing the items at indexes.

## Discussion

Discussion When you call this method, Photos first removes the items in the indexes parameter from the collection, and then inserts them at the location specified by the toIndex parameter. 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.

## 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)
- [replaceAssets(at:withAssets:)](photos/phassetcollectionchangerequest/replaceassets(at:withassets:).md)
