user3766930 user3766930 - 1 year ago 50
iOS Question

Alamofire does not want to accept my parameters in the query - it says extra argument in the call

I wrote a function in

for fetching data based on different parameters. The very beginning of the function is:

func makePostQuery(_ parameters: [String:AnyObject], url: String)

Alamofire.request(url, parameters: (parameters), method: .post)
.responseJSON { response in

switch response.result {
case .success:

but the problem is that
is highlighted and raises error:

Extra argument `parameters` in call

The parameters for example are constructed like this:

var params = [
"long": lon as AnyObject,
"lat": lat as AnyObject,
"startDate": DateCalc.convertValueToDate(defaults.float(forKey: "startDate")) as AnyObject
] as [String: AnyObject]

Answer Source

You have a wrong order of parameters. Try this instead:

Alamofire.request(url, method: .post, parameters: parameters)