GooglePlaces Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
GMSAutocompleteFetcher
@interface GMSAutocompleteFetcher : NSObject
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.
-
Parameters
filter
|
The filter to apply to the results. This parameter may be nil.
|
-
Delegate to be notified with autocomplete prediction results.
-
Filter to apply to autocomplete suggestions (can be nil).
-
-
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.
Declaration
Swift
func sourceTextHasChanged(_ text: String?)
Objective-C
- (void)sourceTextHasChanged:(nullable NSString *)text;
Parameters
text
|
The partial text to autocomplete.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-27 UTC.
[null,null,["Last updated 2025-08-27 UTC."],[[["\u003cp\u003e\u003ccode\u003eGMSAutocompleteFetcher\u003c/code\u003e simplifies the process of getting autocomplete predictions as the user types.\u003c/p\u003e\n"],["\u003cp\u003eIt might not request predictions for every text change to optimize performance.\u003c/p\u003e\n"],["\u003cp\u003ePredictions are only returned for the most recent text provided.\u003c/p\u003e\n"],["\u003cp\u003eA delegate is notified with the prediction results.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the predictions using a filter and track queries with a session token.\u003c/p\u003e\n"]]],[],null,["# GooglePlaces Framework Reference\n\nGMSAutocompleteFetcher\n======================\n\n @interface GMSAutocompleteFetcher : NSObject\n\n`GMSAutocompleteFetcher` is a wrapper around the lower-level autocomplete APIs that encapsulates\nsome of the complexity of requesting autocomplete predictions as the user is typing. Calling\nsourceTextHasChanged will generally result in the provided delegate being called with\nautocomplete predictions for the queried text, with the following provisos:\n\n- The fetcher may not necessarily request predictions on every call of sourceTextHasChanged if several requests are made within a short amount of time.\n- The delegate will only be called with prediction results if those predictions are for the text supplied in the most recent call to sourceTextHasChanged.\n- `\n ``\n ``\n `\n\n ### [-initWithFilter:](#/c:objc(cs)GMSAutocompleteFetcher(im)initWithFilter:)\n\n `\n ` \n Initialize the fetcher. \n\n #### Declaration\n\n Swift \n\n init(filter: ../Classes/GMSAutocompleteFilter.html?)\n\n Objective-C \n\n - (nonnull instancetype)initWithFilter:(nullable ../Classes/GMSAutocompleteFilter.html *)filter;\n\n #### Parameters\n\n |----------------|----------------------------------------------------------------|\n | ` `*filter*` ` | The filter to apply to the results. This parameter may be nil. |\n\n- `\n ``\n ``\n `\n\n ### [delegate](#/c:objc(cs)GMSAutocompleteFetcher(py)delegate)\n\n `\n ` \n Delegate to be notified with autocomplete prediction results. \n\n #### Declaration\n\n Swift \n\n weak var delegate: (any ../Protocols/GMSAutocompleteFetcherDelegate.html)? { get set }\n\n Objective-C \n\n @property (nonatomic, weak, nullable) id\u003c../Protocols/GMSAutocompleteFetcherDelegate.html\u003e delegate;\n\n- `\n ``\n ``\n `\n\n ### [autocompleteFilter](#/c:objc(cs)GMSAutocompleteFetcher(py)autocompleteFilter)\n\n `\n ` \n Filter to apply to autocomplete suggestions (can be nil). \n\n #### Declaration\n\n Swift \n\n var autocompleteFilter: ../Classes/GMSAutocompleteFilter.html? { get set }\n\n Objective-C \n\n @property (nonatomic, strong, nullable) ../Classes/GMSAutocompleteFilter.html *autocompleteFilter;\n\n- `\n ``\n ``\n `\n\n ### [-provideSessionToken:](#/c:objc(cs)GMSAutocompleteFetcher(im)provideSessionToken:)\n\n `\n ` \n Provide a [GMSAutocompleteSessionToken](../Classes/GMSAutocompleteSessionToken.html) for tracking the specific autocomplete query flow. \n\n #### Declaration\n\n Swift \n\n func provide(_ sessionToken: ../Classes/GMSAutocompleteSessionToken.html?)\n\n Objective-C \n\n - (void)provideSessionToken:\n (nullable ../Classes/GMSAutocompleteSessionToken.html *)sessionToken;\n\n- `\n ``\n ``\n `\n\n ### [-sourceTextHasChanged:](#/c:objc(cs)GMSAutocompleteFetcher(im)sourceTextHasChanged:)\n\n `\n ` \n Notify the fetcher that the source text to autocomplete has changed.\n\n This method should only be called from the main thread. Calling this method from another thread\n will result in undefined behavior. Calls to [GMSAutocompleteFetcherDelegate](../Protocols/GMSAutocompleteFetcherDelegate.html) methods will also be\n called on the main thread.\n\n This method is non-blocking. \n\n #### Declaration\n\n Swift \n\n func sourceTextHasChanged(_ text: String?)\n\n Objective-C \n\n - (void)sourceTextHasChanged:(nullable NSString *)text;\n\n #### Parameters\n\n |--------------|-----------------------------------|\n | ` `*text*` ` | The partial text to autocomplete. |"]]