<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Data/range(of:options:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DataV5range2of7options2inSnySiGSgAC_So19NSDataSearchOptionsVAItF"
  },
  "title" : "range(of:options:in:)"
}
-->

# range(of:options:in:)

Finds the range of the specified data as a subsequence of this data, if it exists.

```
func range(of dataToFind: Data, options: Data.SearchOptions = [], in range: Range<Data.Index>? = nil) -> Range<Data.Index>?
```

## Parameters

`dataToFind`

The data to be searched for.

`options`

Options for the search. Default value is `[]`.

`range`

The range of this data in which to perform the search. Default value is `nil`, which means the entire content of this data.

## Return Value

A `Range` specifying the location of the found data, or nil if a match could not be found.

## Discussion

Precondition: `range` must be in the bounds of the Data.

---

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)