---
title: "NSUnionRange(_:_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nsunionrange(_:_:)"
---

# NSUnionRange(_:_:)

Returns the union of the specified ranges.

## Declaration

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

## Return Value

Return Value A range covering all indices in and between range1 and range2. If one range is completely contained in the other, the returned range is equal to the larger range.

## See Also

### Managing ranges

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