Iphone ASIHTTPRequest缓存正在使应用程序崩溃
我有以下代码:Iphone ASIHTTPRequest缓存正在使应用程序崩溃,iphone,objective-c,cocoa-touch,asihttprequest,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]]];
+ (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'
因为setDownloadCache
不是ASIFormDataRequest
中定义的实例方法
根据ASIHTTPRequest
文档:
您的异常说明了这一切“”-[ASIFormDataRequest setDownloadCache:]:无法识别的选择器发送到实例0x9a0140
”那么是否仍有其他方法可以使用ASIFormDataRequest设置缓存?那么我有什么方法可以保存数据呢?它也被JSON解析。[ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]];添加上述行可能会有所帮助。我不熟悉AsitpRequest。以前从未使用过此API。
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadCache:[ASIDownloadCache sharedCache]];