转换为Swift 3后,我尝试修复所有错误。 但这个错误让我感到恶心:
无法使用类型'的参数列表调用'dataTask'(使用:NSMutableURLRequest,completionHandler:(Data?,URLResponse?,NSError?) - > Void)'
在这行代码中(它在最后一行):
let request = NSMutableURLRequest(url: myUrl!)
request.httpMethod = "POST"
let para = ["userId" : user_ID]
let boundary = generateBoundaryString()
let imageA = images[pos]! as UIImage
print(imageA)
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
let imageData = UIImageJPEGRepresentation(imageA, 1)
request.httpBody = createBodyWithParameters(para, filePathKey: "file", imageDataKey: imageData!, boundary: boundary)
URLSession.shared.dataTask(with:request, completionHandler: { (data:NSData, response:URLResponse?, error:NSError?) -> Void in
代码在这里继续,但这对解决方案来说并不重要。
答案 0 :(得分:4)
编译器想要
...(data: Data?, response:URLResponse?, error:Error?)
和
...(data, response, error)
但我建议完全省略类型注释
{{1}}