<!--
{
  "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/NSOrderedSet/init(array:range:copyItems:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOrderedSet(im)initWithArray:range:copyItems:"
  },
  "title" : "init(array:range:copyItems:)"
}
-->

# init(array:range:copyItems:)

Initializes a newly allocated set with the objects that are contained in the specified range of an array, optionally copying the items.

```
convenience init(array set: [Any], range: NSRange, copyItems flag: Bool)
```

## Parameters

`set`

An array of objects to add to the new set.

    If the same object appears more than once in array, it is represented only once in the returned ordered set.

`range`

The range of objects in `array` to add to the ordered set.

`flag`

If <doc://com.apple.documentation/documentation/Swift/true> the objects are copied to the ordered set; otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Return Value

An initialized ordered set containing a uniqued collection of the objects contained in specified range of the array.

## See Also

[`+  orderedSetWithArray:`](/documentation/Foundation/NSOrderedSet/orderedSetWithArray:)

Creates and returns a set containing a uniqued collection of the objects contained in a given array.

[`+  orderedSetWithArray:range:copyItems:`](/documentation/Foundation/NSOrderedSet/orderedSetWithArray:range:copyItems:)

Creates and returns a new ordered set for a specified range of objects in an array.



---

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)