螺栓框架continueWithBlock错误

时间:2015-06-20 21:17:34

标签: swift amazon-s3 cocoapods bolts-framework bftask

我已经在AWS s3工作了一段时间,直到最近才遇到一些问题。我通过cocoapods导入框架。最近,我根据this post重新安装了cocoapods。

之后,我有一百万和一个使用未声明的类型:错误,most in primitive types。我最终通过卸载cocoapods,重新安装cocoapods,删除,清理,然后为我的特定项目重新安装pod来解决这个问题(大多数情况下)(还有一堆项目清理)。

我遇到了一个没有包含Bolts的问题(即使我相信它是AWSCore的一部分)。我将pod Bolts添加到我的Podfile中,并将#import <Bolts/Bolts.h>添加到我的obj-C中 - &gt; Swift桥文件。

现在,Bolts得到了认可,但我收到了错误&#34;无法调用&#39; continueWithBlock&#39;&#34;使用类型&#39;((BFTask!) - &gt; _)&#39;的参数列表使用以下代码时出错:

transfer_manager.getObject(request).continueWithBlock(//error here
                    {(task: BFTask!) in
                           //completion logic
                            return nil //was not necessary prior
                    })

bridge.h:

#import <Bolts/Bolts.h> //was unneeded before reinstalling cocoapods
#import <AWSCore/AWSCore.h>
#import <AWSS3/AWSS3.h>
#import <AWSDynamoDB/AWSDynamoDB.h>
#import <AWSSQS/AWSSQS.h>
#import <AWSSNS/AWSSNS.h>
#import <AWSCognito/AWSCognito.h>

最后,我的Podfile:

platform :ios, '8.0'enter code here

source 'https://github.com/CocoaPods/Specs.git'
pod 'Bolts' #was unneeded before reinstalling cocoapods
pod 'AWSCore'
pod 'AWSAutoScaling'
pod 'AWSCloudWatch'
pod 'AWSDynamoDB'
pod 'AWSEC2'
pod 'AWSElasticLoadBalancing'
pod 'AWSKinesis'
pod 'AWSLambda'
pod 'AWSMachineLearning'
pod 'AWSMobileAnalytics'
pod 'AWSS3'
pod 'AWSSES'
pod 'AWSSimpleDB'
pod 'AWSSNS'
pod 'AWSSQS'
pod 'AWSCognito'

关于如何(因为我看到问题)的任何想法让Xcode / Swift再次正确识别Bolts / BFTask?

3 个答案:

答案 0 :(得分:4)

你可以使用AWSTask!取代BFTask! (它是一个子类)来沉默xcode。

答案 1 :(得分:2)

通过将我的Pod恢复到上一个​​稳定配置后,我尝试了与您相同的步骤,解决了这个确切的头撞问题。

clear
clc
close all

I=imread('circuit.tif');
%BW = bwmorph(I,'skel',1);
BW = edge(I,'canny');

[H, T, R] = hough(BW);
P = houghpeaks(H, 100);
lines = houghlines(BW, T, R, P, 'FillGap',5, 'MinLength', 20);

%// NEW \\
imshow(true(size(BW)));

hold on
for k = 1:numel(lines)

    %// Delete current line displayed
   CurrLine = findobj('Type','line');
   delete(CurrLine);

   %// Plot current line
   xy = [lines(k).point1; lines(k).point2];
   plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');

   drawnow

   %// Create file name and capture axes content
   CurrentFrame = getframe(gca);

   ImageName = sprintf('Image_%i',k);

   %// Save image
   imwrite(CurrentFrame.cdata,[ImageName '.jpg'],'jpg');

end

很难做到这一点,但希望它是一个临时的解决方法。我的应用程序正在构建&amp;现在运作正常。希望这对你有所帮助。

答案 2 :(得分:1)

只需将BFTask的单词替换为AWSTask。

导入以下文件&amp;框架

#import <AssetsLibrary/AssetsLibrary.h>
#import "AWSS3.h"
#import "Constants.h"

在此处提供文件路径

   - (void)fileUpload {
                NSError *error = nil;
                if (![[NSFileManager defaultManager] createDirectoryAtPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"upload"]
                                               withIntermediateDirectories:YES
                                                                attributes:nil
                                                                     error:&error]) {
                    NSLog(@"reating 'upload' directory failed: [%@]", error);
                }

                //    UIImage *image = [UIImage imageNamed:@"Screen Shot 2015-06-16 at 7.25.09 pm"];
                //
                //    NSString *fileName = [[[NSProcessInfo processInfo] globallyUniqueString] stringByAppendingString:@".png"];
                //    NSString *filePath = [[NSTemporaryDirectory() stringByAppendingPathComponent:@"upload"] stringByAppendingPathComponent:fileName];
                //    NSData * imageData = UIImagePNGRepresentation(image);
                //
                //    [imageData writeToFile:filePath atomically:YES];

                NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Untitled" ofType:@"mov"];

                //    NSError *error = nil;
                NSData *data = [NSData dataWithContentsOfFile:filePath];
                if(data == nil && error!=nil) {
                    //Print error description
                }

                AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
                uploadRequest.body = [NSURL fileURLWithPath:filePath];
                uploadRequest.key = @"video1.mov";
                uploadRequest.bucket = S3BucketName;

                [self upload:uploadRequest];
                // Do any additional setup after loading the view, typically from a nib.
            }

上传使用以下方法

 - (void)upload:(AWSS3TransferManagerUploadRequest *)uploadRequest {
                        AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];


                        [[transferManager upload:uploadRequest] continueWithBlock:^id(AWSTask *task) {
                            if (task.error) {
                                if ([task.error.domain isEqualToString:AWSS3TransferManagerErrorDomain]) {
                                    switch (task.error.code) {
                                        case AWSS3TransferManagerErrorCancelled:
                                        case AWSS3TransferManagerErrorPaused:
                                        {
                                            dispatch_async(dispatch_get_main_queue(), ^{
                                                //update UI
                                            });
                                        }
                                            break;

                                        default:
                                            NSLog(@"Upload failed: [%@]", task.error);
                                            break;
                                    }
                                } else {
                                    NSLog(@"Upload failed: [%@]", task.error);
                                }
                            }

                            if (task.result) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    //Successfully uploaded.
                                    NSLog(@"Successfully uploaded");

                                    //update UI here.
                                });
                            }

                            return nil;
                        }];
                    }