<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextSelectionDataSource/lineFragmentRange(for:inContainerAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextSelectionDataSource(im)lineFragmentRangeForPoint:inContainerAtLocation:"
  },
  "title" : "lineFragmentRange(for:inContainerAt:)"
}
-->

# lineFragmentRange(for:inContainerAt:)

Returns the range of the line fragment that contains the point you specify.

```
func lineFragmentRange(for point: CGPoint, inContainerAt location: any NSTextLocation) -> NSTextRange?
```

## Parameters

`point`

The starting point that contains the line fragment, in the coordinate system of `location`.

`location`

The location of the line fragment.

## Return Value

An `NSTextRange` that describes the location of the line fragment, or nil if the range isn’t found.

---

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)