<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/replaceValue(at:inPropertyWithKey:withValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)replaceValueAtIndex:inPropertyWithKey:withValue:"
  },
  "title" : "replaceValue(at:inPropertyWithKey:withValue:)"
}
-->

# replaceValue(at:inPropertyWithKey:withValue:)

Replaces the object at the specified index in the collection specified by the passed key.

```
func replaceValue(at index: Int, inPropertyWithKey key: String, withValue value: Any)
```

## Discussion

The method `replaceIn<Key>:atIndex:` is invoked if it exists. If no corresponding scripting-KVC-compliant method (`-replaceIn<Key>atIndex:`) is found, this method invokes `-mutableArrayValueForKey:` and mutates the result.

> Note:
> Prior to OS X version 10.4, this method did not invoke `-mutableArrayValueForKey:`.

---

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)