GooglePlaces Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
GMSAutocompleteViewControllerDelegate
@protocol GMSAutocompleteViewControllerDelegate <NSObject>
Protocol used by GMSAutocompleteViewController
, to communicate the user’s interaction
with the controller to the application.
-
Called when a place has been selected from the available autocomplete predictions.
Implementations of this method should dismiss the view controller as the view controller will not
dismiss itself.
-
Called when a non-retryable error occurred when retrieving autocomplete predictions or place
details. A non-retryable error is defined as one that is unlikely to be fixed by immediately
retrying the operation.
Only the following values of GMSPlacesErrorCode
are retryable:
- kGMSPlacesNetworkError
- kGMSPlacesServerError
- kGMSPlacesInternalError
All other error codes are non-retryable.
Declaration
Objective-C
- (void)viewController:(nonnull GMSAutocompleteViewController *)viewController
didFailAutocompleteWithError:(nonnull NSError *)error;
Parameters
viewController
|
|
error
|
The NSError that was returned.
|
-
Called when the user taps the Cancel button in a GMSAutocompleteViewController
.
Implementations of this method should dismiss the view controller as the view controller will not
dismiss itself.
-
Called when the user selects an autocomplete prediction from the list but before requesting
place details.
Returning NO from this method will suppress the place details fetch and didAutocompleteWithPlace
will not be called.
Parameters
viewController
|
|
prediction
|
|
-
Called once every time new autocomplete predictions are received.
-
Called once immediately after a request for autocomplete predictions is made.
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\u003eGMSAutocompleteViewControllerDelegate\u003c/code\u003e is a protocol used to handle user interactions within the \u003ccode\u003eGMSAutocompleteViewController\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to inform the app when a place is selected, when an error occurs, or if the user cancels the process.\u003c/p\u003e\n"],["\u003cp\u003eDelegate methods also allow the app to track autocomplete prediction updates and selections.\u003c/p\u003e\n"],["\u003cp\u003eImplementations of this protocol are responsible for dismissing the \u003ccode\u003eGMSAutocompleteViewController\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `GMSAutocompleteViewControllerDelegate` protocol manages user interactions with the `GMSAutocompleteViewController`. Key actions include handling place selection via `didAutocompleteWithPlace:`, reporting errors with `didFailAutocompleteWithError:`, and responding to cancellations with `wasCancelled:`. It also includes notification when the user selects a prediction ( `didSelectPrediction:`), and when autocomplete predictions are requested or updated via `didRequestAutocompletePredictions:` and `didUpdateAutocompletePredictions:`. For selection or cancel, the view controller should be dismissed manually.\n"],null,["# GooglePlaces Framework Reference\n\nGMSAutocompleteViewControllerDelegate\n=====================================\n\n @protocol GMSAutocompleteViewControllerDelegate \u003cNSObject\u003e\n\nProtocol used by [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html), to communicate the user's interaction\nwith the controller to the application.\n- `\n ``\n ``\n `\n\n ### [-viewController:didAutocompleteWithPlace:](#/c:objc(pl)GMSAutocompleteViewControllerDelegate(im)viewController:didAutocompleteWithPlace:)\n\n `\n ` \n Called when a place has been selected from the available autocomplete predictions.\n\n Implementations of this method should dismiss the view controller as the view controller will not\n dismiss itself. \n\n #### Declaration\n\n Swift \n\n func viewController(_ viewController: ../Classes/GMSAutocompleteViewController.html, didAutocompleteWith place: ../Classes/GMSPlace.html)\n\n Objective-C \n\n - (void)viewController:(nonnull ../Classes/GMSAutocompleteViewController.html *)viewController\n didAutocompleteWithPlace:(nonnull ../Classes/GMSPlace.html *)place;\n\n #### Parameters\n\n |------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*viewController*` ` | The [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html) that generated the event. |\n | ` `*place*` ` | The [GMSPlace](../Classes/GMSPlace.html) that was returned. |\n\n- `\n ``\n ``\n `\n\n ### [-viewController:didFailAutocompleteWithError:](#/c:objc(pl)GMSAutocompleteViewControllerDelegate(im)viewController:didFailAutocompleteWithError:)\n\n `\n ` \n Called when a non-retryable error occurred when retrieving autocomplete predictions or place\n details. A non-retryable error is defined as one that is unlikely to be fixed by immediately\n retrying the operation.\n\n Only the following values of [GMSPlacesErrorCode](../Enums/GMSPlacesErrorCode.html) are retryable:\n - kGMSPlacesNetworkError\n - kGMSPlacesServerError\n - kGMSPlacesInternalError\n\n All other error codes are non-retryable.\n\n \u003cbr /\u003e\n\n #### Declaration\n\n Swift \n\n func viewController(_ viewController: ../Classes/GMSAutocompleteViewController.html, didFailAutocompleteWithError error: any Error)\n\n Objective-C \n\n - (void)viewController:(nonnull ../Classes/GMSAutocompleteViewController.html *)viewController\n didFailAutocompleteWithError:(nonnull NSError *)error;\n\n #### Parameters\n\n |------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*viewController*` ` | The [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html) that generated the event. |\n | ` `*error*` ` | The `NSError` that was returned. |\n\n- `\n ``\n ``\n `\n\n ### [-wasCancelled:](#/c:objc(pl)GMSAutocompleteViewControllerDelegate(im)wasCancelled:)\n\n `\n ` \n Deprecated\n\n Use Places Swift SDK's (\u003chttps://developers.google.com/maps/documentation/places/ios-sdk/google-places-swift\u003e) placeAutocomplete API instead. \n Called when the user taps the Cancel button in a [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html).\n\n Implementations of this method should dismiss the view controller as the view controller will not\n dismiss itself. \n\n #### Declaration\n\n Swift \n\n func wasCancelled(_ viewController: ../Classes/GMSAutocompleteViewController.html)\n\n Objective-C \n\n - (void)wasCancelled:(nonnull ../Classes/GMSAutocompleteViewController.html *)viewController;\n\n #### Parameters\n\n |------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*viewController*` ` | The [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html) that generated the event. |\n\n- `\n ``\n ``\n `\n\n ### [-viewController:didSelectPrediction:](#/c:objc(pl)GMSAutocompleteViewControllerDelegate(im)viewController:didSelectPrediction:)\n\n `\n ` \n Called when the user selects an autocomplete prediction from the list but before requesting\n place details.\n\n Returning NO from this method will suppress the place details fetch and didAutocompleteWithPlace\n will not be called. \n\n #### Declaration\n\n Swift \n\n optional func viewController(_ viewController: ../Classes/GMSAutocompleteViewController.html, didSelect prediction: ../Classes/GMSAutocompletePrediction.html) -\u003e Bool\n\n Objective-C \n\n - (BOOL)viewController:(nonnull ../Classes/GMSAutocompleteViewController.html *)viewController\n didSelectPrediction:(nonnull ../Classes/GMSAutocompletePrediction.html *)prediction;\n\n #### Parameters\n\n |------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*viewController*` ` | The [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html) that generated the event. |\n | ` `*prediction*` ` | The [GMSAutocompletePrediction](../Classes/GMSAutocompletePrediction.html) that was selected. |\n\n- `\n ``\n ``\n `\n\n ### [-didUpdateAutocompletePredictions:](#/c:objc(pl)GMSAutocompleteViewControllerDelegate(im)didUpdateAutocompletePredictions:)\n\n `\n ` \n Called once every time new autocomplete predictions are received. \n\n #### Declaration\n\n Swift \n\n optional func didUpdateAutocompletePredictions(_ viewController: ../Classes/GMSAutocompleteViewController.html)\n\n Objective-C \n\n - (void)didUpdateAutocompletePredictions:\n (nonnull ../Classes/GMSAutocompleteViewController.html *)viewController;\n\n #### Parameters\n\n |------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*viewController*` ` | The [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html) that generated the event. |\n\n- `\n ``\n ``\n `\n\n ### [-didRequestAutocompletePredictions:](#/c:objc(pl)GMSAutocompleteViewControllerDelegate(im)didRequestAutocompletePredictions:)\n\n `\n ` \n Called once immediately after a request for autocomplete predictions is made. \n\n #### Declaration\n\n Swift \n\n optional func didRequestAutocompletePredictions(_ viewController: ../Classes/GMSAutocompleteViewController.html)\n\n Objective-C \n\n - (void)didRequestAutocompletePredictions:\n (nonnull ../Classes/GMSAutocompleteViewController.html *)viewController;\n\n #### Parameters\n\n |------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*viewController*` ` | The [GMSAutocompleteViewController](../Classes/GMSAutocompleteViewController.html) that generated the event. |"]]