GMSAutocompleteViewControllerから場所を選択していくつかの問題が発生した後に収集されたデータを渡そうとしています。私はこのエラーが発生しています:タイプ 'NSTaggedPointerString'(0x1afeb5c50)の値を 'UILabel'(0x1afedd508)にキャストできませんでした。私が間違っていることを確信していない...すべての助けてくれてありがとう!GoogleプレイスのデータをUILabelに渡します
// 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 = place.placeID
placesClient.lookUpPlaceID(placeID, 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)")
})
//
let selectedPlace = place.name
self.placeNameLabel = (selectedPlace as AnyObject) as! UILabel
self.dismiss(animated: true, completion: nil)
setupConfirmationPopUp()
}
// label I am trying to pass the place.name to
lazy var placeNameLabel: UILabel = {
let placeNameLabel = UILabel()
placeNameLabel.textColor = .black
placeNameLabel.text = "Are you sure you want to add < Placename Placename > to places you have visited?"
placeNameLabel.frame = CGRect(x: 50, y: 120, width: 200, height: CGFloat.greatestFiniteMagnitude) // use constraints later
placeNameLabel.numberOfLines = 0
placeNameLabel.lineBreakMode = NSLineBreakMode.byWordWrapping
placeNameLabel.sizeToFit()
placeNameLabel.layer.zPosition = 1
placeNameLabel.isUserInteractionEnabled = true
return placeNameLabel
}()