I get the error message "missing argument for parameter 'completed' in call", after writing the following code:
func downloadForecastData(completed: DownloadComplete) { / Alamofire.request(FORECAST_URL, withMethod: .get, parameters: nil, encoding: .json).responseJSON { response in let result = response.result
if let dict = result.value as? Dictionary<String, AnyObject> {
if let list = dict["list"] as? [Dictionary<String, AnyObject>] {
for obj in list { let forecast = Forecast(weatherDict: obj) self.forecasts.append(forecast) print(obj) } self.forecasts.remove(at: 0) self.tableView.reloadData() } }
completed() } }Any ideas of what I am doing wrong?
I get the error when I am calling the function inside another function like this:
self.downloadForecastData()Appreciate all the help!
Since the method takes a parameter, you have to pass a parameter. In this case, the type DownloadComplete seems to be a closure, so you have to fix this by passing a closure like this:
self.downloadForecastData({ print "completed" })or just
self.downloadForecastData({ })if you want nothing to happen.