<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextSearchAggregator-swift.struct",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:5UIKit22UITextSearchAggregatorV"
  },
  "title" : "UITextSearchAggregator"
}
-->

# UITextSearchAggregator

The methods you use on a find session’s aggregator to collect matching text ranges for a search.

```
struct UITextSearchAggregator<DocumentIdentifier> where DocumentIdentifier : Hashable
```

## Overview

To track text ranges that match the search, call these methods on the aggregator for the searchable object implementing the [`UITextSearching`](/documentation/UIKit/UITextSearching-53wjq) protocol for a [`UITextSearchingFindSession`](/documentation/UIKit/UITextSearchingFindSession).

## Topics

### Tracking search results

[`func foundRange(UITextRange, searchString: String, document: DocumentIdentifier)`](/documentation/UIKit/UITextSearchAggregator-swift.struct/foundRange(_:searchString:document:))

Adds a text range to the set of matches.

[`func invalidateFoundRange(UITextRange, document: DocumentIdentifier)`](/documentation/UIKit/UITextSearchAggregator-swift.struct/invalidateFoundRange(_:document:))

Removes a text range from the set of matches.

[`func invalidate()`](/documentation/UIKit/UITextSearchAggregator-swift.struct/invalidate())

Invalidates all currently shown ranges.

[`func finishedSearching()`](/documentation/UIKit/UITextSearchAggregator-swift.struct/finishedSearching())

Finishes the search for text ranges.

[`var allFoundRanges: [UITextRange]`](/documentation/UIKit/UITextSearchAggregator-swift.struct/allFoundRanges)

An ordered set of all the text ranges that match the search.



---

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)