2

I use GMSAutocompleteFetcher in my swift project to search places. Here I install 'GooglePlaces''GooglePlacePicker' 'GoogleMaps' with pods and write all things as in link https://developers.google.com/places/ios-api/autocomplete#use_the_fetcher but after write in textFieldDidChange I got result according to it in delegate method :

func didAutocomplete(with predictions: [GMSAutocompletePrediction]) {
        let resultsStr = NSMutableString()
        for prediction in predictions {
            resultsStr.appendFormat("%@\n", prediction.attributedFullText)

        }

but in resultsStr got value :

 Ca{
    GMSAutocompleteMatch = "<GMSAutocompleteMatchFragment: 0x608000223940>";
}lifornia{
}

It should be "California"

Fabio Berger
  • 1,921
  • 2
  • 24
  • 29

1 Answers1

9

Swift 3.0 code..

Your prediction.attributedFullText attributed text to convert first in the string and then you get string type result.

   func didAutocomplete(with predictions: [GMSAutocompletePrediction]) {
    let resultsStr = NSMutableString()
    for prediction in predictions {
        resultsStr.appendFormat("%@\n", prediction.attributedPrimaryText.string)
    }
    print(resultsStr) //California
    }
Arjun Yadav
  • 1,369
  • 1
  • 10
  • 23