Graphics Programs Reference
In-Depth Information
• An
NSURL
instance contains the location of a web application in URL format.
For many web services, the URL will be composed of the base address, the web
application you are communicating with, and any arguments that are being
passed.
• An
NSURLRequest
instance holds all the data necessary to communicate with a
web server. This includes an
NSURL
object, as well as a caching policy, a limit on
how long you will give the web server to respond, and additional data passed
through the HTTP protocol. (
NSMutableURLRequest
is the mutable subclass
of
NSURLRequest
.)
• An
NSURLConnection
instance is responsible for actually making the connec-
tion to a web server, sending the information in its
NSURLRequest
, and gather-
ing the response from the server.
Formatting URLs and requests
The form of a web service request varies depending on who implements the web service;
there are no set-in-stone rules when it comes to web services. You will need to find the
documentation for the web service to know how to format a request. As long as a client
application sends the server what it wants, you have a working exchange.
The Big Nerd Ranch Forum's RSS feed wants a URL that looks like this:
http://forums.bignerdranch.com/smartfeed.php?limit=1_DAY&sort_by=standard
&feed_type=RSS2.0&feed_style=COMPACT
You can see that the base URL is
forums.bignerdranch.com
, the web application
is
smartfeed
, and there are five arguments. These arguments are required by the
smart-
feed
web application.
This is a pretty common form for a web service request. Generally, a request URL looks
like this:
http://baseURL.com/serviceName?argumentX=valueX&argumentY=valueY