Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Now that we’ve talked a little bit about the types of things people use web services for, and two of the most common web service architectures, it’s time to talk about the technical details involved in communicating with web services.
Before we talk about how to send and receive structured data with a web service, we need to learn how to do the basics: sending and receiving raw data from the Web. This can be accomplished in a couple of different ways, but we’ll cover the use of two classes, NSURLRequest and NSURLConnection, here because these classes are also available to iOS applications.
Using these two classes requires the use of a delegate. We’ve seen bits and pieces of delegates throughout this book, but this is the first time we’re going to implement a full suite of delegate methods. A delegate is just an instance of an object that responds to some well-known set of methods. In the case of NSURLConnection, the connection delegate is what receives notifications about data that is downloaded, connection success, and connection failure.