2016-02-29 41 views
0

當我嘗試調用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 
     } 
    } 
} 

我不明白接下來我要添加哪些建議? 我正試圖在地圖上顯示一個位置,並帶有來自班級的位置。

回答

1

您收到抱怨,因爲您的geocodeLocation(location: String)函數需要參數類型爲String

你需要一些字符串傳遞,如:

geocodeLocation("123 Main st")

+0

謝謝它的工作! – ABlach