Stacky
Stacky

Reputation: 103

How to download data from a website introducing some parameters in Objective C

I'm new in objective C and I'm having problems to find this.

My app is going to be: 1) user introduces a parameter, and 2) my app returns the data in a list.

I have to do this using a website, but i don't know how to know do the request, and then how to pick up and parse the info.

How can I start??

Upvotes: 1

Views: 611

Answers (2)

Christopher Nassar
Christopher Nassar

Reputation: 554

It doesn't seem clear to me what you are trying to do. If you are trying to call a webservice with some parameters or just calling a website plus parameters in the end of it?

If webservice , just use the ASIHTTP Library located in here:

http://allseeing-i.com/ASIHTTPRequest/

If website, just append your parameter to the end of the string and call it.

Upvotes: 0

LuisEspinoza
LuisEspinoza

Reputation: 8538

I think that you can handle the filter parameter in the server with a cgi or php, in the app, make the request and get the response.

1.- Get the parameter from the user like a NSString.
2.- Create a NSURL from the string (and the server adress string).
3.- The use the class method dataWithContentsOfURL from NSData to initialize a NSData object from the response url.
4.- NSData is really flexible, so you can do anything with it.

Note: dataWithContentsOfURL is synchronous, so if you want async, take a look at Grand Central Dispatch.

Upvotes: 2

Related Questions