我在从Google Places存储地点详细信息时遇到了一些问题。我可以很好地构建应用程序,但是当我从...中选择一个位置时会崩溃GMSAutocompleteViewController
......“无法将'GMSPlace'(0x10075bec8)类型的值转换为'NSString'(0x1afec1398)。”
我想保存选定的地点数据,然后将该数据发送到 UIView 和 UITableView 中显示。不知道我做错了什么......
// MARK: GOOGLE AUTO COMPLETE DELEGATE
func viewController(_ viewController: GMSAutocompleteViewController, didAutocompleteWith place: GMSPlace) {
// Do something with the selected place.
// A hotel in Saigon with an attribution.
// let placeID = "ChIJV4k8_9UodTERU5KXbkYpSYs"
let placeID = GMSPlace.self
placesClient.lookUpPlaceID((placeID as AnyObject) as! String, callback: { (place, error) -> Void in
if let error = error {
print("lookup place id query error: \(error.localizedDescription)")
return
}
guard let place = place else {
print("No place details for \(placeID)")
return
}
print("Place name \(place.name)")
print("Place address \(place.formattedAddress)")
print("Place placeID \(place.placeID)")
print("Place attributions \(place.attributions)")
})
self.dismiss(animated: true, completion: nil)
setupConfirmationPopUp()
}