Summary

In this chapter, we saw that it takes a lot less code to parse/build JSON objects with the NSJSONSerialization class as compared to parsing/building XML objects. However, we do have a lot more control on how the document is parsed using the NSXMLParser class. The key thing to keep in mind with both the NSJSONSerialization class and the NSXMLParser class is that we need to remember to check that optional variables do not contain a nil value, before attempting to use them.

While it seems that the majority of newer services are using the JSON format over XML, it is good to have a working knowledge of both formats because there is still a large percentage of services that use XML.

Get Swift: Developing iOS Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.