符合协议Swift的GMSAutocompleteResultsViewControllerDelegate

时间:2016-01-31 01:17:55

标签: swift protocols google-places-api google-maps-sdk-ios

我正在尝试使用Google Maps SDK for IOS中的一些示例代码。下面的代码给出了一条错误消息:类型ViewController不符合协议GMSAutocompleteResultsViewControllerDelegate。见下面的代码。有谁知道什么不符合。

extension ViewController: GMSAutocompleteResultsViewControllerDelegate {
    func resultsController(resultsController: GMSAutocompleteResultsViewController!,
        didAutocompleteWithPlace place: GMSPlace!) {
            searchController?.active = false
            // Do something with the selected place.
            print("Place name: ", place.name)
            print("Place address: ", place.formattedAddress)
            print("Place attributions: ", place.attributions)
    }

    func resultsController(resultsController: GMSAutocompleteResultsViewController!,
        didAutocompleteWithError error: NSError!){
            // TODO: handle the error.
            print("Error: ", error.description)
    }
}

1 个答案:

答案 0 :(得分:1)

不幸的是,网站上的示例代码不正确。协议方法实际上称为didFailAutocompleteWithError,而不是didAutocompleteWithError