Swift4.0中使用AFN框架出现了Extra argument 'progress' in call
的错误, 代码如下:
get(urlString, parameters: parameters, progress: nil, success: { (task: URLSessionDataTask, result: AnyObject) in
print(result)
}) { (task: URLSessionDataTask, error: Error) in
print(error)
}
问题原因: 参数类型传入不对
解决: 以后在Swift中尽量使用类型推导, 不然就要跟方法的参数传入一样的类型:
get(urlString, parameters: parameters, progress: nil, success: { (task, result) in
print(result)
}) { (task, error) in
print(error)
}