Web Services in Mac Cocoa Programming

By: Aaron Hillegass Viewed: 153195 times    

Web services are simply an HTTP request and response whereby each may be carrying XML data. So using a Web service from Cocoa is simply a matter of being able to send HTTP requests and receive responses. It also may require generating and parsing XML.

Figure: Your Average Web Service in Action

HTTP requests and responses are handled by NSURL, NSURLRequest, and NSURLConnection.

Figure: Classes for Making HTTP Requests

Generating and parsing XML are typically done by NSXMLDocument and NSXMLNode. Suppose that you have an NSData containing this XML:

<?xml version="1.0" encoding="UTF-8"?>
<person>
<first>Larry</first>
<last>Furg</last>
</person>

NSXMLDocument will parse it into a handy tree.

Figure: Parsed XML Document

Most Viewed Articles (in Cocoa )

Latest Articles (in Cocoa)

Comment on this tutorial