---
title: "replaceObjects(at:with:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutablearray/replaceobjects(at:with:)"
---

# replaceObjects(at:with:)

Replaces the objects in the receiving array at locations specified with the objects from a given array.

## Declaration

```swift
func replaceObjects(at indexes: IndexSet, with objects: [Any])
```

## Parameters

- `indexes`: The indexes of the objects to be replaced.
- `objects`: The objects with which to replace the objects in the receiving array at the indexes specified by indexes. The count of locations in indexes must equal the count of objects.

## Discussion

Discussion The indexes in indexes are used in the same order as the objects in objects. If objects or indexes is nil, this method raises an exception.

## See Also

### Related Documentation

- [removeObject(at:)](foundation/nsmutablearray/removeobject(at:).md)
- [insert(_:at:)](foundation/nsmutablearray/insert(_:at:)-5dbx5.md)

### Replacing Objects

- [replaceObject(at:with:)](foundation/nsmutablearray/replaceobject(at:with:).md)
- [replaceObjects(in:withObjectsFrom:range:)](foundation/nsmutablearray/replaceobjects(in:withobjectsfrom:range:).md)
- [replaceObjects(in:withObjectsFrom:)](foundation/nsmutablearray/replaceobjects(in:withobjectsfrom:).md)
- [setArray(_:)](foundation/nsmutablearray/setarray(_:).md)
