---
title: "compareFoundRange:toRange:inDocument:"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextsearching-53wjq/comparefoundrange:torange:indocument:"
---

# compareFoundRange:toRange:inDocument:

Compares ranges from the set of matches the aggregator provides to determine navigation order.

## Declaration

```occ
- (NSComparisonResult) compareFoundRange:(UITextRange *) foundRange toRange:(UITextRange *) toRange inDocument:(UITextSearchDocumentIdentifier) document;
```

## Parameters

- `foundRange`: The range of characters in a text container to compare from.
- `toRange`: The range of characters in a text container to compare to.
- `document`: A string that uniquely identifies the document containing the text ranges. Nil when searching a single document.

## Return Value

Return Value Returns the result of comparing the two text ranges.

## Discussion

Discussion The system calls this method during a find session to determine which UITextRange to highlight next when a user taps the “next” or “previous” button.

## See Also

### Handling searches

- [performTextSearchWithQueryString:usingOptions:resultAggregator:](uikit/uitextsearching-53wjq/performtextsearchwithquerystring:usingoptions:resultaggregator:.md)
- [UITextSearchAggregator](uikit/uitextsearchaggregator-c.protocol.md)
- [compareOrderFromDocument:toDocument:](uikit/uitextsearching-53wjq/compareorderfromdocument:todocument:.md)
- [UITextSearchDocumentIdentifier](uikit/uitextsearchdocumentidentifier.md)
