<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextSelectionNavigation/destinationSelection(for:direction:destination:extending:confined:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextSelectionNavigation(im)destinationSelectionForTextSelection:direction:destination:extending:confined:"
  },
  "title" : "destinationSelection(for:direction:destination:extending:confined:)"
}
-->

# destinationSelection(for:direction:destination:extending:confined:)

Returns a new selection that results from applying the navigation operations you specify to the text selection you provide.

```
func destinationSelection(for textSelection: NSTextSelection, direction: NSTextSelectionNavigation.Direction, destination: NSTextSelectionNavigation.Destination, extending: Bool, confined: Bool) -> NSTextSelection?
```

## Parameters

`textSelection`

The source selection.

`direction`

One of the available [`NSTextSelectionNavigation.Direction`](/documentation/AppKit/NSTextSelectionNavigation/Direction) directions.

`destination`

One of the available [`NSTextSelectionNavigation.Destination`](/documentation/AppKit/NSTextSelectionNavigation/Destination) destinations.

`extending`

Whether this selection extends an existing selection.

`confined`

Whether to confine movement to the existing selection.

## Return Value

A new [`NSTextSelection`](/documentation/AppKit/NSTextSelection), or `nil` if the operation doesn’t produce a logically valid result.

## Discussion

If `confined` is `true`, confine any movement to the text element that the selection already lies within.

---

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)