---
title: "exchangeObject(at:withObjectAt:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutablearray/exchangeobject(at:withobjectat:)"
---

# exchangeObject(at:withObjectAt:)

Exchanges the objects in the array at given indexes.

## Declaration

```swift
func exchangeObject(at idx1: Int, withObjectAt idx2: Int)
```

## Parameters

- `idx1`: The index of the object with which to replace the object at index idx2.
- `idx2`: The index of the object with which to replace the object at index idx1.

## See Also

### Rearranging Content

- [sort(using:)](foundation/nsmutablearray/sort(using:)-4eh07.md)
- [sort(comparator:)](foundation/nsmutablearray/sort(comparator:).md)
- [sort(options:usingComparator:)](foundation/nsmutablearray/sort(options:usingcomparator:).md)
- [sort(_:context:)](foundation/nsmutablearray/sort(_:context:).md)
- [sort(using:)](foundation/nsmutablearray/sort(using:)-537vs.md)
