ios - 使用 Xcode 6.4 在 swift 中使用 GMSPlacesClient 时出错

标签 ios xcode swift google-maps-sdk-ios

我正在关注 Google API 文档并尝试查找当前设备周围的位置。我正在尝试使用 GMSPlacesClient.currentPlaceWithCallback。

文档示例是

GMSPlacesClient.currentPlaceWithCallback({ (placeLikelihoods: GMSPlaceLikelihoodList,error) -> Void in
        if error != nil {
            println("Current Place error: \(error.localizedDescription)")
            return
        }

        for likelihood in placeLikelihoods.likelihoods {
            if let likelihood = likelihood as? GMSPlaceLikelihood {
                let place = likelihood.place
                println("Current Place name \(place.name) at likelihood \(likelihood.likelihood)")
                println("Current Place address \(place.formattedAddress)")
                println("Current Place attributions \(place.attributions)")
                println("Current PlaceID \(place.placeID)")
            }
        }
    })

但是构建失败并出现错误 Cannot invoke 'currentPlaceWithCallback' with an argument list of type '((GMSPlaceLikelihoodList, _) -> Void)'

建议请..谢谢

最佳答案

您可以删除 placeLikelihoods 之后的“:GMSPlaceLikelihoodList”,它应该可以工作。对于我使用过的所有 GMSPlaceClient 方法,您不需要在回调中包含参数类型

关于ios - 使用 Xcode 6.4 在 swift 中使用 GMSPlacesClient 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32101736/

相关文章:

xcode - 如何将语言添加到 NSSpellChecker 的可用语言中?

ios - Xcode 6.0.1 Instruments iOS8 - 在设备上进行分析时应用程序表现不正常

ios - JSON AFNetworking iOS 6 查看值是否为 "on"

ios - Swift - 带有 UIPickerView 完成按钮的 UIToolbar 在横向上消失

ios - 在 viewDisappear 之前等待 saveInBackground Parse

c++ - Xcode 中没有可行的重载 '=' 错误(Eclipse 未显示错误)

swift - 访问唯一 AutoID 内的 Firebase 数据

ios - Xcode 核心数据属性

swift - 无法使用 * 类型的对象调用 $function

Swift Firebase - 将数据库快照转换为数组