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

Summary


This chapter presented the common techniques that are used to deal with networked data in Swift-based applications with a particular focus on how to maximize battery usage on portable devices using asynchronous techniques to access data.

As most network requests are likely to provide either a JSON or XML-based representation over HTTP(S), the first section of this chapter covered using NSURLSession and the asynchronous dataTask operations to pull data down from a remote server. The second and third sections then presented how this data can be parsed from either JSON or XML depending on the format required.

The last section presented how to make network connections directly to deal with protocols other than HTTP; and as an example, showed how a remote git command can be executed to find out what references are available in a remote git repository. This was presented in two forms: as a synchronous API (to demonstrate the technique of how to work with streams, and to explain the git protocol...