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'
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为
setDownloadCache
不是ASIFormDataRequest
中定义的实例方法。根据
ASIHTTPRequest
文档:http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_a_download_cache
你的异常说明了一切“
'-[ASIFormDataRequest setDownloadCache:]: 无法识别的选择器发送到实例0x9a0140”
Because
setDownloadCache
is not instance method defined inASIFormDataRequest
.As per
ASIHTTPRequest
documentation:http://allseeing-i.com/ASIHTTPRequest/How-to-use#using_a_download_cache
Your exception says it all "
'-[ASIFormDataRequest setDownloadCache:]: unrecognized selector sent to instance 0x9a0140
"