Programming Tutorials

Web Services in Mac Cocoa Programming

By: Aaron Hillegass in Cocoa Tutorials on 2010-09-24  

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






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Cocoa )

Latest Articles (in Cocoa)