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

Loading data from URLs


The most common way to load data from a remote network source is to use an HTTP (or HTTPS) URL of the form https://raw.githubusercontent.com/alblue/com.packtpub.swift.essentials/master/CustomViews/CustomViews/SampleTable.json.

URLs can be manipulated with the NSURL class, which comes from the Foundation module (which is transitively imported from the UIKit module). The main NSURL initializer takes a String initializer with a full URL, although other initializers exist to create relative URLs or for references to file paths.

The NSURLSession class is typically used to perform operations with URLs, and individual sessions can be created through the initializer or the standard shared session can be used. The NSURLConnection class was used in older versions of iOS and Mac OS X. References to this class can still be seen in some tutorials, or may be required if Mac OS X 10.8 or iOS 6 needs to be supported; otherwise, the NSURLSession class should be preferred.

The NSURLSession...