Contents

textLineFragment(for:isUpstreamAffinity:)

Returns a text line fragment from a specific text location in the document.

Declaration

func textLineFragment(for textLocation: any NSTextLocation, isUpstreamAffinity: Bool) -> NSTextLineFragment?

Parameters

  • textLocation:

    A text location that a text line fragment contains.

  • isUpstreamAffinity:

    A Boolean value that indicates whether the text line fragment ends at the text location you provide.

Return Value

The text line fragment that contains or ends at the text location you provide, or nil if there isn’t a match.

Discussion

Set isUpstreamAffinity to true to find a text fragment by its element range end location, such as when you enumerate over line fragments in reverse order. Set isUpstreamAffinity to false to find a text fragment that contains textLocation.

See Also

Getting line fragments