gpt4 book ai didi

ios - 从 Swift 2.2 升级到 Swift 3.0 后模糊使用 `continue`

转载 作者:可可西里 更新时间:2023-11-01 00:50:08 33 4
gpt4 key购买 nike

我有一个 swift 项目,我正在那里使用 Amazon Web Services。

我有一个函数负责将图像上传到我的 S3 存储桶,在 Swift 2.2 中它运行良好,代码如下:

let credentialsProvider = AWSCognitoCredentialsProvider(regionType:CognitoRegionType,
identityPoolId:CognitoIdentityPoolId)
let configuration = AWSServiceConfiguration(region:CognitoRegionType, credentialsProvider:credentialsProvider)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration



let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest.body = NSURL(string: "file://"+pathToFile)
uploadRequest.key = NSProcessInfo.processInfo().globallyUniqueString + "." + ext
uploadRequest.bucket = S3BucketName
uploadRequest.contentType = contentType + ext

let transferManager = AWSS3TransferManager.defaultS3TransferManager()
transferManager.upload(uploadRequest).continueWithBlock { (task) -> AnyObject! in

if (task.completed) {
...

现在,升级到 Swift 3 后,我有:

let credentialsProvider = AWSCognitoCredentialsProvider(regionType:CognitoRegionType,
identityPoolId:CognitoIdentityPoolId)
let configuration = AWSServiceConfiguration(region:CognitoRegionType, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = configuration



let uploadRequest = AWSS3TransferManagerUploadRequest()
uploadRequest?.body = URL(string: "file://"+pathToFile)
uploadRequest?.key = ProcessInfo.processInfo.globallyUniqueString + "." + ext
uploadRequest?.bucket = S3BucketName
uploadRequest?.contentType = contentType + ext

let transferManager = AWSS3TransferManager.default()
transferManager?.upload(uploadRequest).continueWithBlock { (task) -> AnyObject! in

if (task.isCompleted) {

现在在最后一条语句中 transferManager?.upload(uploadRequest).continueWithBlock 抛出一个错误

'continueWithBlock' has been renamed to 'continue(_:)'

所以我听从他们的建议并将其更改为:

transferManager?.upload(uploadRequest).continue { 

但随后它抛出一个错误:

Ambigous use of continue

可用的方法在这里:

enter image description here

但我不确定在这种情况下我可以使用哪一个。你能帮我吗?

最佳答案

好的,我找到了问题,它比我想象的要容易......这里提到了:https://github.com/aws/aws-sdk-ios/issues/473并说要改变

transferManager?.upload(uploadRequest).continue { ... }

transferManager?.upload(uploadRequest).continue ({ ... })

这种情况下的方法命名确实很烦人,但它确实有效。

关于ios - 从 Swift 2.2 升级到 Swift 3.0 后模糊使用 `continue`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40103873/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com