Some kind of nonsense gives google places

func searchCity(nameCity :String? = "A") { let filter = GMSAutocompleteFilter() filter.type = GMSPlacesAutocompleteTypeFilter.city let placesClient = GMSPlacesClient() placesClient.autocompleteQuery(nameCity!, bounds: nil, filter: filter, callback: { (results, error: Error?) -> Void in self.filterArray.removeAll() if let error = error { print("Autocomplete error \(error)") } if results != nil { for result in results! { for type in result.types { if type == "locality" { let city = result.attributedPrimaryText.string let country = result.attributedSecondaryText!.string self.filterArray.append(["title": city, "descr":country, "id": result.placeID ?? ""]) } } } } self.filterTableView.reloadData() }) } 

Even considering the filter

 filter.type = GMSPlacesAutocompleteTypeFilter.city 

I get a lot of extra information. And when trying to somehow weed it out, I get not only the cities, but also sat down in the load.

I need to do a search only by city! Any ideas ?

Ps do not criticize for the code, it is very dirty for now = \

  • Apparently, instead of searching, you are requesting options for autocomplex. - Max Mikheyenko
  • @MaxMikheyenko googled, but found nothing to search for, only autocomplete. Perhaps you have a useful reference. - Svyatoslav Boyko

0