ASIHTTPRequest缓存正在崩溃应用程序

时间:2011-10-18 20:53:15

标签: iphone objective-c cocoa-touch asihttprequest

我有以下代码:

+ (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'

1 个答案:

答案 0 :(得分:0)

因为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:]: unrecognized selector sent to instance 0x9a0140

相关问题