在尝试使用 AWSTransferutility 通过 Swift 上传照片时,我收到此错误。对成员 async(execute:) 的模糊引用我搜索了类似的问题,但没有找到解决方案。
func uploadS3Background (dict: NSMutableDictionary) {
let transferUtility = AWSS3TransferUtility.default()
let expression = AWSS3TransferUtilityUploadExpression()
let completionHandler = { (task, error) -> Void in
DispatchQueue.main.async(execute: {
})
}
transferUtility.uploadFile(URL(fileURLWithPath: dict.object(forKey: "url") as! String),
bucket: "bucketname/images",
key: (dict.object(forKey: "filename") as! String),
contentType: "image/png",
expression: expression,
completionHandler).continueWith { (task) -> AnyObject! in
if let error = task.error
{
print("Error: \(error.localizedDescription)")
}
if let _ = task.result
{
// Do something with uploadTask.
}
return nil;
}
}
在完成 block 之外,我没有收到在主队列上调度的错误。最佳答案
在您的 View Controller 中声明这一点 -
var completionHandler: AWSS3TransferUtilityUploadCompletionHandlerBlock?
然后使用
self.completionHandler = { (task, error) -> Void in
DispatchQueue.main.async(execute: {
})
}
关于ios - 在完成 block AWS S3 Swift 3 中对成员异步执行的模糊引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42936298/