I have an array which includes URLs of JSON feeds. I am using ASIHTTPRequest to download the feed and process it. Each feed contains several JSON entries or objects. The request downloads the data and selects only one object and stores it.
The feeds URLs look like this: http:www.*.com/id.json, where id is some string. After downloading the data and selecting the object, I’d like to store the id in a dictionary as a key that maps to a value of the object downloaded.
How can I pass that string with the request? So for example:
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
request.tag = 3;
[request setDelegate:self];
[request startAsynchronous];
Now in requestFinished, I can identify that request as follows: if (request.tag == 3. Along with tag of 3, I’d like to send the ID. So I can do something with it in if (request.tag == 3). Is there some property where I can pass a string or any data along with a request?
You can pass your own dictionary of data in the
userInfoproperty, which, like thetagproperty, can be read back on the request after receiving the response.See documentation.
If you want to post data like a web page posts a form, you can use the ASIFormDataRequest subclass. It makes it very easy to send POST requests with strings you add individually:
See the documentation.