Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASIHTTPRequest Multiple POST parameters

I'm using ASIFormDataRequest to post data to a server, and I need to post an array of values (strings in the example below). I'm using an enumerator to loop through each and add them to the request, but only the last one comes through - the behaviour you'd expect for setPostValue, not addPostValue.

Any idea why only one value is coming through?

NSEnumerator *pupilEnumerator = [pupils objectEnumerator];
id pupil;
while ((pupil = [pupilEnumerator nextObject])) {
  [request addPostValue:pupil forKey:@"pupils"];
}

Note this also occurs for addFile and addPostData.

Cheers.

like image 450
Ryan Townsend Avatar asked Sep 11 '26 10:09

Ryan Townsend


1 Answers

Your loop just keeps replacing the "pupils" value. Get rid of the loop and try [request addPostValue:pupils forKey:@"pupils"];

like image 102
picciano Avatar answered Sep 13 '26 00:09

picciano



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!