我正在尝试使用AFNetworking& swift 3.0,但我收到如下错误。 Cannot convert value of type '(AFMultipartFormData!) -> Void' to expected argument type '((AFMultipartFormData?) -> Void)!'
let url = "http://localhost:9000/api/content"
var params = [
"familyId":"10000",
"contentBody" : "Some body content for the test application",
"name" : "the name/title",
"typeOfContent":"photo"
]
let manager = AFHTTPRequestOperationManager()
manager.post(
url,
parameters: params,
constructingBodyWith: { (formData: AFMultipartFormData!) -> Void in
formData.appendPartWithFileData(imageData!, name: "Photo", fileName: "photo.jpg", mimeType: "image/jpeg")
},
success: { (operation: AFHTTPRequestOperation?, responseObject: Any?) in
self.onSuccess(
operation: operation!,
responseObject: responseObject! as AnyObject
)
},
failure: { (operation: AFHTTPRequestOperation?, error) in
print("Error 1: " + error!.localizedDescription)
self.onFailure(operation: operation)
})
有人知道如何解决这个问题吗? 任何帮助将不胜感激。提前谢谢。