<!--
{
  "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/NSIntersectionRange(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@F@NSIntersectionRange"
  },
  "title" : "NSIntersectionRange(_:_:)"
}
-->

# NSIntersectionRange(_:_:)

Returns the intersection of the specified ranges.

```
func NSIntersectionRange(_ range1: NSRange, _ range2: NSRange) -> NSRange
```

## Return Value

A range describing the intersection of `range1` and `range2`—that is, a range containing the indices that exist in both ranges.

## Discussion

If the returned range’s length field is 0, then the two ranges don’t intersect, and the value of the location field is undefined.

---

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)