Book Image

Swift Essentials - Second Edition

By : Alex Blewitt
Book Image

Swift Essentials - Second Edition

By: Alex Blewitt

Overview of this book

Swift was considered one of the biggest innovations last year, and certainly with Swift 2 announced at WWDC in 2015, this segment of the developer space will continue to be hot and dominating. This is a fast-paced guide to provide an overview of Swift programming and then walks you through in detail how to write iOS applications. Progress through chapters on custom views, networking, parsing and build a complete application as a Git repository, all by using Swift as the core language
Table of Contents (17 chapters)
Swift Essentials Second Edition
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Chapter 6. Parsing Networked Data

Many iOS applications need to communicate with other servers or devices. This chapter presents both HTTP and non-HTTP networking in Swift, and how data can be parsed from either JSON or XML. It first demonstrates how to load data efficiently from URLs, followed by how to stream larger data responses. It then concludes with how to perform both synchronous and asynchronous network requests over protocols other than HTTP.

This chapter will present the following topics:

  • Loading data from URLs

  • Updating the user interface from a background thread

  • Parsing JSON and XML data

  • Stream-based connections

  • Asynchronous data communication