<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSTextCheckingResult/range(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextCheckingResult(im)rangeAtIndex:"
  },
  "title" : "range(at:)"
}
-->

# range(at:)

Returns the result type that the range represents.

```
func range(at idx: Int) -> NSRange
```

## Parameters

`idx`

The index of the result.

## Return Value

The range of the result.

## Discussion

A result must have at least one range, but may optionally have more, for example, to represent regular expression capture groups.

Passing [`range(at:)`](/documentation/Foundation/NSTextCheckingResult/range(at:)) the value `0` always returns the value of the [`range`](/documentation/Foundation/NSTextCheckingResult/range) property. Additional ranges, if any, will have indexes from `1` to `numberOfRanges``-1`.

---

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)