Book Image

Swift 2 Blueprints

By : Cecil Costa
Book Image

Swift 2 Blueprints

By: Cecil Costa

Overview of this book

In this book, you will work through seven different projects to get you hands-on with developing amazing applications for iOS devices. We start off with a project that teaches you how to build a utility app using Swift. Moving on, we cover the concepts behind developing an entertainment or social networking related application, for example, a small application that helps you to share images, audio, and video files from one device to another. You’ll also be guided through create a city information app with customized table views, a reminder app for the Apple Watch, and a game app using SpriteKit. By the end of this book, you will have the required skillset to develop various types of iOS applications with Swift that can run on different iOS devices. You will also be well versed with complex techniques that can be used to enhance the performance of your applications.
Table of Contents (15 chapters)
Swift 2 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Coding the initial view controller


The InitialViewController class will display the possible cities where the user is located. Let's continue with the InitialViewController class and complete its code. To complete this code, we need to think about where we are going to store the received information. We will need two arrays of CityInfo: one is to store every object received from the server and the other is to store the objects that are shown after the user's filter. These arrays must be stored as properties:

    private var cities = [CityInfo]()
    private var citiesDisplayed = [CityInfo]()

At this point, we can complete the didUpdateLocations method, which belongs to the CLLocationManagerDelegate protocol. Now, we can request information of the cities that are around us. Type the following code to implement the didUpdateLocations method, replacing the yourgeonamesuser word with the username you registered on geonames:

    func locationManager(manager: CLLocationManager!, didUpdateLocations...