GMSAutocompleteFetcher is a wrapper around the lower-level autocomplete APIs that encapsulates some of the complexity of requesting autocomplete predictions as the user is typing.
Calling sourceTextHasChanged will generally result in the provided delegate being called with autocomplete predictions for the queried text, with the following provisos:
- The fetcher may not necessarily request predictions on every call of sourceTextHasChanged if several requests are made within a short amount of time.
- The delegate will only be called with prediction results if those predictions are for the text supplied in the most recent call to sourceTextHasChanged.
Public Member Functions
|Initialize the fetcher. |
|Provide a |
|Notify the fetcher that the source text to autocomplete has changed. |
< GMSAutocompleteFetcherDelegate >
|Delegate to be notified with autocomplete prediction results. |
|Filter to apply to autocomplete suggestions (can be nil). |
Member Function Documentation
|- (instancetype) initWithFilter:||(nullable GMSAutocompleteFilter *)||filter|
Initialize the fetcher.
filter The filter to apply to the results. This parameter may be nil.
|- (void) provideSessionToken:||(nullable GMSAutocompleteSessionToken *)||sessionToken|
GMSAutocompleteSessionToken for tracking the specific autocomplete query flow.
|- (void) sourceTextHasChanged:||(nullable NSString *)||text|
Notify the fetcher that the source text to autocomplete has changed.
This method should only be called from the main thread. Calling this method from another thread will result in undefined behavior. Calls to
GMSAutocompleteFetcherDelegate methods will also be called on the main thread.
This method is non-blocking.
text The partial text to autocomplete.
|- (id<GMSAutocompleteFetcherDelegate>) delegate
Delegate to be notified with autocomplete prediction results.
|- (GMSAutocompleteFilter*) autocompleteFilter
Filter to apply to autocomplete suggestions (can be nil).