Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get postValue from finished ASIHTTPRequest

I'd like to know how to retrieve a post value from a finished ASIHTTPRequest.

When I perform the request I do this:

[request setPostValue:uniqueID forKey:@"bookUniqueId"];
NSFileManager *fileManager = [[NSFileManager alloc]init];
if (![fileManager fileExistsAtPath:tempDir]) {
    [fileManager createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:nil];
}
[fileManager release];

tempDir = [[tempDir stringByAppendingPathComponent:uniqueID]stringByAppendingPathExtension:@"zip"];
[request setDownloadDestinationPath:tempDir];
[request setDelegate:self];
[request startAsynchronous];

because I want to download the zip file, named like the ID of my book.

In the - (void)requestFinished:(ASIHTTPRequest *)request method I need that ID to unzip the file. I can't save the ID in an ivar because I want to support multiple asynchronous downloads.

How can I do this? Is there something similar to the inexistent method [request postValueForKey: key] ?

like image 779
Lolloz89 Avatar asked Feb 11 '26 13:02

Lolloz89


1 Answers

Whenver you create your ASIFormDataRequest Just set its userinfo and get it like this.

For setting user Info use this.

[request setUserInfo:[NSDictionary dictionaryWithObject:@"YOUR_VALUE" forKey:@"YOUR_KEY"]];

For getting user Info use this.

-(void)requestFinished:(ASIHTTPRequest *)request
{
     NSDictionary *dict = [request userInfo];
     NSString *str = [dict objectForKey:@"YOUR_KEY"];
}
like image 111
Mehul Mistri Avatar answered Feb 13 '26 14:02

Mehul Mistri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!