<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextRange/union(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextRange(im)textRangeByFormingUnionWithTextRange:"
  },
  "title" : "union(_:)"
}
-->

# union(_:)

Returns a new text range by forming the union with the text range you provide.

```
func union(_ textRange: NSTextRange) -> Self
```

## Parameters

`textRange`

The range to use to create the union.

## Return Value

An [`NSTextRange`](/documentation/AppKit/NSTextRange) that represent the union of the two ranges.

---

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)