【问题标题】:BlackRaccoon while downloading a file giving error: unrecognized selector sent to instance 0xcd609f0BlackRaccoon 下载文件时出现错误:无法识别的选择器发送到实例 0xcd609f0
【发布时间】:2014-02-20 00:54:48
【问题描述】:

我正在使用 BlackRaccoon 从 FTP 服务器下载文件。以下是代码:

- (IBAction)download:(id)sender {


    downloadData = [NSMutableData dataWithCapacity: 1];

    downloadFile = [[BRRequestDownload alloc] initWithDelegate: self];

    downloadFile.path = @"psnewsletter.pdf";
    downloadFile.hostname = @"server";
    downloadFile.username = @"user";
    downloadFile.password = @"pswd";

    [downloadFile start];  
}

它给出以下错误

2014-02-20 11:48:43.526 BlackHillPrimarySchool[2036:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainViewController requestFailed:]: unrecognized selector sent to instance 0xcd609f0'

任何帮助将不胜感激。

【问题讨论】:

    标签: ios objective-c unrecognized-selector blackraccoon


    【解决方案1】:

    requestFailed: 是您必须在视图控制器中实现的BRRequest 委托方法之一。

    - (void)requestFailed:(BRRequest *)request {
        BRRequestError *reqError = request.error;
        // check the error, handle as needed.
    }
    

    我不确定您的代码是如何编译的。这是协议的必需方法。

    【讨论】:

    • 这似乎是初始化程序中的一个错误:- (instancetype)initWithDelegate:(id)delegate; 应该是- (instancetype)initWithDelegate:(id<BRRequestDelegate>)delegate;
    • @Sebastian 很好。这就是问题所在。
    • 我刚刚向 BlackRaccoon 项目提交了一个错误报告,以修复委托参数的类型。
    猜你喜欢
    • 1970-01-01
    • 2012-04-04
    • 1970-01-01
    • 2019-04-13
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多