<!--
{
  "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/subscript(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Subscript",
  "symbol" : {
    "kind" : "Instance Subscript",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOrderedSet(im)objectAtIndexedSubscript:"
  },
  "title" : "subscript(_:)"
}
-->

# subscript(_:)

Returns the object at the specified index of the set.

```
subscript(idx: Int) -> Any { get }
```

## Parameters

`idx`

The object located at index.

## Return Value

If `idx` is beyond the end of the ordered set (that is, if index is greater than or equal to the value returned by count), an [`rangeException`](/documentation/Foundation/NSExceptionName/rangeException) is raised.

## Discussion

This method is the same as [`object(at:)`](/documentation/Foundation/NSOrderedSet/object(at:)).

---

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)