当前位置:  开发笔记 > IOS > 正文

Swift 3:Transfer Utility enumerateToAssignBlocks方法签名

如何解决《Swift3:TransferUtilityenumerateToAssignBlocks方法签名》经验,为你挑选了0个好方法。

官方AWS文档包含以下Objective-c代码

 AWSS3TransferUtility *transferUtility = [AWSS3TransferUtility defaultS3TransferUtility];
[transferUtility
 enumerateToAssignBlocksForUploadTask:^(AWSS3TransferUtilityUploadTask *uploadTask, __autoreleasing AWSS3TransferUtilityUploadProgressBlock *uploadProgressBlockReference, __autoreleasing AWSS3TransferUtilityUploadCompletionHandlerBlock *completionHandlerReference) {
     NSLog(@"%lu", (unsigned long)uploadTask.taskIdentifier);

     // Use `uploadTask.taskIdentifier` to determine what blocks to assign.

     *uploadProgressBlockReference = // Reassign your progress feedback block.
     *completionHandlerReference = // Reassign your completion handler.
 }
 downloadTask:^(AWSS3TransferUtilityDownloadTask *downloadTask, __autoreleasing AWSS3TransferUtilityDownloadProgressBlock *downloadProgressBlockReference, __autoreleasing AWSS3TransferUtilityDownloadCompletionHandlerBlock *completionHandlerReference) {
     NSLog(@"%lu", (unsigned long)downloadTask.taskIdentifier);

     // Use `downloadTask.taskIdentifier` to determine what blocks to assign.

     *downloadProgressBlockReference =  // Reassign your progress feedback block.
     *completionHandlerReference = // Reassign your completion handler.
 }];

我尝试将其转换为Swift 3(仅限上传任务)

transferUtility.enumerateToAssignBlocks(forUploadTask:
        {

            let progressPointer = AutoreleasingUnsafeMutablePointer(&uploadProgressBlock)
            let completionPointer = AutoreleasingUnsafeMutablePointer(&completionBlock)

            progress = progressPointer
            completion = completionPointer

    }
        , downloadTask: nil)

但是Xcode会抛出以下错误

无法将type() - >()的值转换为预期的参数类型[...]

有人在Swift 3中工作吗?可能方法签名已经改变

编辑:

我申请了@donkon回答:

        transferUtility.enumerateToAssignBlocks(forUploadTask: { (uploadTask:AWSS3TransferUtilityUploadTask, progress:AutoreleasingUnsafeMutablePointer<(@convention(block) (AWSS3TransferUtilityTask, Progress) -> Void)?>?, error: AutoreleasingUnsafeMutablePointer<(@convention(block) (AWSS3TransferUtilityUploadTask, Error?) -> Void)?>?) in

                        let progressPointer = AutoreleasingUnsafeMutablePointer(&self.progressBlock)
                        let completionPointer = AutoreleasingUnsafeMutablePointer(&self.completionHandler)
        //

                        progress = progressPointer

                        completion = completionPointer


    }, downloadTask: nil)

现在Xcode告诉进度和完成都是值,不能更改.

推荐阅读
手机用户2402852307
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有