---
title: "NSIntersectionRange(_:_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nsintersectionrange(_:_:)"
---

# NSIntersectionRange(_:_:)

Returns the intersection of the specified ranges.

## Declaration

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

## Return Value

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

## Discussion

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.

## See Also

### Managing ranges

- [NSEqualRanges(_:_:)](foundation/nsequalranges(_:_:).md)
- [NSLocationInRange(_:_:)](foundation/nslocationinrange(_:_:).md)
- [NSMakeRange(_:_:)](foundation/nsmakerange(_:_:).md)
- [NSMaxRange(_:)](foundation/nsmaxrange(_:).md)
- [NSRangeFromString(_:)](foundation/nsrangefromstring(_:).md)
- [NSStringFromRange(_:)](foundation/nsstringfromrange(_:).md)
- [NSUnionRange(_:_:)](foundation/nsunionrange(_:_:).md)
