---
title: "enumerateCaretOffsetsInLineFragment(at:using:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextselectiondatasource/enumeratecaretoffsetsinlinefragment(at:using:)"
---

# enumerateCaretOffsetsInLineFragment(at:using:)

Enumerates all the insertion point caret offsets from left to right in visual order.

## Declaration

```swift
func enumerateCaretOffsetsInLineFragment(at location: any NSTextLocation, using block: (CGFloat, any NSTextLocation, Bool, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

- `location`: The NSTextLocation to start from.
- `block`: The closure to invoke once for each logical caret edge in the line fragment, in left-to-right visual order. End the enumeration early by returning false.

## Discussion

Discussion The caretOffset is in the coordinate system for the text container. When leadingEdge is true, it indicates that caretOffset is at the logical edge preceding the character. For left-to-right characters, the caret is on the left, and on the right for right-to-left characters.

## See Also

### Enumerating components of the selection

- [enumerateContainerBoundaries(from:reverse:using:)](uikit/nstextselectiondatasource/enumeratecontainerboundaries(from:reverse:using:).md)
- [enumerateSubstrings(from:options:using:)](uikit/nstextselectiondatasource/enumeratesubstrings(from:options:using:).md)
