在使用CLGeocoder调用参数#1时丢失参数
问题描述:
当我尝试调用viewDidLoad中的geocodeLocation时,我在调用中获取参数#1的错误缺失参数,这是一种随机错误或者我正在做一些完全错误的事情?在使用CLGeocoder调用参数#1时丢失参数
override func viewDidLoad(){
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
geocodeLocation() //Missing argument for parameter #1 in call
}
func geocodeLocation(location: String){
let geocode = CLGeocoder()
geocode.geocodeAddressString(location) { (objects, error) -> Void in
if error != nil {
print(error)
} else {
self.createActionSheet(objects!)
self.locationArray = objects
}
}
}
我不明白接下来我要添加哪些建议? 我正试图在地图上显示一个位置,并带有来自班级的位置。
答
您收到抱怨,因为您的geocodeLocation(location: String)
函数需要参数类型为String
。
你需要一些字符串传递,如:
geocodeLocation("123 Main st")
谢谢它的工作! – ABlach