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.
Declaration
Swift
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace)
Objective-C
- (void)viewController:(nonnull GMSAutocompleteViewController *)viewController didAutocompleteWithPlace:(nonnull GMSPlace *)place;
Parameters
viewController
The
GMSAutocompleteViewController
that generated the event.place
The
GMSPlace
that was returned. -
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
Declaration
Swift
func viewController(_ viewController: GMSAutocompleteViewController, didFailAutocompleteWithError error: any Error)
Objective-C
- (void)viewController:(nonnull GMSAutocompleteViewController *)viewController didFailAutocompleteWithError:(nonnull NSError *)error;
Parameters
viewController
The
GMSAutocompleteViewController
that generated the event.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.
Declaration
Swift
func wasCancelled(_ viewController: GMSAutocompleteViewController)
Objective-C
- (void)wasCancelled:(nonnull GMSAutocompleteViewController *)viewController;
Parameters
viewController
The
GMSAutocompleteViewController
that generated the event. -
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.
Declaration
Swift
optional func viewController(_ viewController: GMSAutocompleteViewController, didSelect prediction: GMSAutocompletePrediction) -> Bool
Objective-C
- (BOOL)viewController:(nonnull GMSAutocompleteViewController *)viewController didSelectPrediction:(nonnull GMSAutocompletePrediction *)prediction;
Parameters
viewController
The
GMSAutocompleteViewController
that generated the event.prediction
The
GMSAutocompletePrediction
that was selected. -
Called once every time new autocomplete predictions are received.
Declaration
Swift
optional func didUpdateAutocompletePredictions(_ viewController: GMSAutocompleteViewController)
Objective-C
- (void)didUpdateAutocompletePredictions: (nonnull GMSAutocompleteViewController *)viewController;
Parameters
viewController
The
GMSAutocompleteViewController
that generated the event. -
Called once immediately after a request for autocomplete predictions is made.
Declaration
Swift
optional func didRequestAutocompletePredictions(_ viewController: GMSAutocompleteViewController)
Objective-C
- (void)didRequestAutocompletePredictions: (nonnull GMSAutocompleteViewController *)viewController;
Parameters
viewController
The
GMSAutocompleteViewController
that generated the event.