---
title: replaceObject
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/osarray/replaceobject
---

# replaceObject

Removes a current member of the array and replaces it with another object.

## Declaration

```occ
bool replaceObject(uint32_t index, const OSMetaClassBase *anObject);
```

## Parameters

- `index`: Zero based index less than the array count to add the object.
- `anObject`: Object to be added to the array.

## Return Value

Return Value True on success, which retains the added object and releases the current member, or false on failure which does not retain the object and leaves the current member.

## See Also

### Accessing Elements

- [getObject](driverkit/osarray/getobject.md)
- [getLastObject](driverkit/osarray/getlastobject.md)
- [getNextIndexOfObject](driverkit/osarray/getnextindexofobject.md)
- [setObject](driverkit/osarray/setobject-3bore.md)
- [setObject](driverkit/osarray/setobject-4ys3x.md)
- [iterateObjects](driverkit/osarray/iterateobjects.md)
- [removeObject](driverkit/osarray/removeobject.md)
- [OSArrayAppendValue](driverkit/osarrayappendvalue.md)
- [OSArrayReplaceValue](driverkit/osarrayreplacevalue.md)
