Getting ready

In this recipe, we will investigate how to read and write XML data using functionalities within the Foundation framework. However, while the classes that help with reading XML data are available on all of Apple's platforms, the classes that assist with writing XML data are only available on the macOS platform.

This is an unfortunate oversight and means that if you need to write XML data within an iOS app, you will likely need to look for a third-party helper or build your own. We will investigate third-party helpers at the end of this recipe.

To investigate both reading and writing XML using the Foundation framework, we need to create a new macOS-based playground instead of an iOS-based playground, which we created earlier. ...

Get Swift 4 Programming Cookbook 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.