使用AWSContinuationBlock发送兼容的指针块类型

时间:2015-07-31 06:10:14

标签: ios objective-c amazon-web-services

尝试使用AWSS3TransferManager运行块时出现以下错误:

incompatible block pointer types sending 'id ((^)(void)) to parameter of type 'AWSContinuationBlock' (aka id (^)(AWSTask *__strong))

我相信这是由于不同的块类型,我目前没有返回任何值,而它期望AWSTask,但我不知道如何返回AWSTask。

_uploadRequest = [AWSS3TransferManagerUploadRequest new];

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
[[transferManager upload:_uploadRequest] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task){

    if (task.error){
        NSLog(@"%@",task.error);
    }
}];

1 个答案:

答案 0 :(得分:3)

错误是由于您提供的阻止BFTask参数的阻止。

BFTask参数更改为AWSTask并返回该参数。

_uploadRequest = [AWSS3TransferManagerUploadRequest new];

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];
[[transferManager upload:_uploadRequest] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(AWSTask *task){

    if (task.error){
        NSLog(@"%@",task.error);
    }

    return task;
}];