<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableOrderedSet/replaceObjects(in:with:count:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableOrderedSet(im)replaceObjectsInRange:withObjects:count:"
  },
  "title" : "replaceObjects(in:with:count:)"
}
-->

# replaceObjects(in:with:count:)

Replaces the objects in the receiving mutable ordered set at the range with the specified number of objects from a given C array.

```
func replaceObjects(in range: NSRange, with objects: UnsafePointer<AnyObject>?, count: Int)
```

## Parameters

`range`

The range of the objects to replace.

`objects`

A C array of objects.

`count`

The number of values from the objects C array to insert in place of the objects in `range`. This number will be the count of the new array—it must not be negative or greater than the number of elements in objects.

## Discussion

Elements are added to the new array in the same order they appear in objects, up to but not including index count.

---

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)