我正在关注 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/