<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/OSArray/replaceObject",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@OSArray@F@replaceObject#i#*1$@S@OSMetaClassBase#"
  },
  "title" : "replaceObject"
}
-->

# replaceObject

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

```
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

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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)