ios - 在完成 block AWS S3 Swift 3 中对成员异步执行的模糊引用

标签 ios xcode amazon-s3

在尝试使用 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 之外,我没有收到在主队列上调度的错误。
enter image description here

最佳答案

在您的 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/

相关文章:

ios - 在飞行模式下,CTCarrier 中的 isoCountryCode 不返回 nil

iphone - 为 UITextView 设置多种数据检测器类型

xcode - 没有 iPhone,如何使用 XCode 截屏?

c - 如何拥有一个返回整数指针的函数数组

iphone - [mapView addOverlay :overlayPolygon]; 时,集合在枚举时发生了变异

php - 在 Laravel 中更改 S3 端点

ios - 在外部点击时移除 View

ios - 参数标签 '(_:)' 不匹配任何可用的重载

amazon-web-services - 跳过 s3 中 csv 文件的页脚到 Athena

amazon-web-services - AWS 配置 Tomcat 的虚拟目录和电子邮件系统