使用 CLGeocoder 的调用中参数 #1 缺少参数
Missing Argument for Parameter #1 in call using CLGeocoder
当我尝试在 viewDidLoad 中调用 geocodeLocation 时,我收到错误消息 missing argument for parameter #1 in call,这是随机错误还是我做错了什么?
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
}
}
}
我不明白我接下来要补充什么,有建议吗?
我正在尝试使用图钉在地图上显示一个位置,该位置来自 class.
您收到投诉是因为您的 geocodeLocation(location: String)
函数需要类型为 String
的参数。
您需要传入一些字符串,例如:
geocodeLocation("123 Main st")
当我尝试在 viewDidLoad 中调用 geocodeLocation 时,我收到错误消息 missing argument for parameter #1 in call,这是随机错误还是我做错了什么?
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
}
}
}
我不明白我接下来要补充什么,有建议吗? 我正在尝试使用图钉在地图上显示一个位置,该位置来自 class.
您收到投诉是因为您的 geocodeLocation(location: String)
函数需要类型为 String
的参数。
您需要传入一些字符串,例如:
geocodeLocation("123 Main st")