andymar
andymar

Reputation: 13

How I can fix Extra Argument In call?

I am writing WeatherApp on Swift. I have problem with compilation which called "Extra argument in call". I am writing HourlyForecast and u can see there my code:

View Controller:

HourlyForecast.downloadDailyForecastWeather { (hourlyForecastArray) in
    for data in hourlyForecastArray {
        print("forecast data: \(data.temp, data.date)")
    }
} 

Part of HourlyForecast.swift:

init(weatherDictionary: Dictionary<String, AnyObject>) {
    let json = JSON(weatherDictionary)
    self._temp = json["temp"].double
    self._date = currentDateFromUnix(unixDate: json["ts"].double!)
    self._weatherIcon = json["weather"]["icon"].stringValue
}

How I can fix it?

Upvotes: 1

Views: 63

Answers (1)

vadian
vadian

Reputation: 285270

You have to interpolate each variable separately

for data in hourlyForecastArray {
    print("forecast data: \(data.temp), \(data.date)") 
}

Notes:

  • Don't use objective-c-ish variable names with leading underscore.
  • In Swift JSON dictionary values are Any not AnyObject.
  • Use Codable, it's much more efficient than SwiftyJSON.

Upvotes: 3

Related Questions