使用 Alamofire 上传图像的代码会触发 SwiftLint 违规。如何修复?
Alamofire.upload(multipartFormData: { (multipartFormData) in
multipartFormData.append(imageData, withName: "profileImage", fileName: "image.png", mimeType: "image/jpg")
}, usingThreshold: UInt64.init(), to: requestURL, method: .post, headers: headers) { (result) in
switch result {
case .success(let upload, _, _):
upload.responseJSON { response in
if let error = response.error {
completionBlock(.failure(error as NSError))
return
}
completionBlock(.success(response))
}
case .failure(let error):
completionBlock(.failure(error as NSError))
}
}
带有尾随闭包违规的多个闭包:当传递多个闭包参数时,不应使用尾随闭包语法。(multiple_closures_with_trailing_closure)