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'
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
"