ASIHTTPRequest 缓存导致应用程序崩溃

发布于 2024-12-10 18:39:29 字数 1204 浏览 0 评论 0原文

我有以下代码:

+ (NSMutableArray*)getTodayData:(NSDate*)today
{
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/ichrono/20110715/60b88126/load_dr_daily_schedule/%@/", [self getDrChronoHost], [dateFormat stringFromDate:today]]];

        ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
        [self addCurrentUserLoginToPostRequest:request];        
        [request setPostValue:[dateFormat stringFromDate:today] forKey:@"target_date"];
        [request setDownloadCache:[ASIDownloadCache sharedCache]];
        [request startSynchronous];

        NSError *error = [request error];
        NSString *responseString;
        if (!error) {
            responseString = [request responseString];
        } else {
            return NULL;
        }
        return [responseString JSONValue];
    }
}

在添加行 [request setDownloadCache:[ASIDownloadCache sharedCache]]; 之前,它工作正常。

我如何得到错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ASIFormDataRequest setDownloadCache:]: unrecognized selector sent to instance 0x9a0140'

I have the following code:

+ (NSMutableArray*)getTodayData:(NSDate*)today
{
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/ichrono/20110715/60b88126/load_dr_daily_schedule/%@/", [self getDrChronoHost], [dateFormat stringFromDate:today]]];

        ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
        [self addCurrentUserLoginToPostRequest:request];        
        [request setPostValue:[dateFormat stringFromDate:today] forKey:@"target_date"];
        [request setDownloadCache:[ASIDownloadCache sharedCache]];
        [request startSynchronous];

        NSError *error = [request error];
        NSString *responseString;
        if (!error) {
            responseString = [request responseString];
        } else {
            return NULL;
        }
        return [responseString JSONValue];
    }
}

It worked fine before I added the line [request setDownloadCache:[ASIDownloadCache sharedCache]];.

How I get the error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ASIFormDataRequest setDownloadCache:]: unrecognized selector sent to instance 0x9a0140'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞旧 2024-12-17 18:39:29

因为setDownloadCache不是ASIFormDataRequest中定义的实例方法。

根据 ASIHTTPRequest 文档:
http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_a_download_cache

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadCache:[ASIDownloadCache sharedCache]];

你的异常说明了一切“'-[ASIFormDataRequest setDownloadCache:]: 无法识别的选择器发送到实例0x9a0140”

Because setDownloadCache is not instance method defined in ASIFormDataRequest.

As per ASIHTTPRequest documentation:
http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_a_download_cache

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadCache:[ASIDownloadCache sharedCache]];

Your exception says it all "'-[ASIFormDataRequest setDownloadCache:]: unrecognized selector sent to instance 0x9a0140"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文