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

Building view controllers with HomeKit


Let's now get started with our controllers with the help of HomeKit. Basically, we will need a view controller for each accessory. In this app, the garage has only one accessory, therefore it has only one view controller. The living room has three accessories: the door, the fan, and the aquarium. As we have three accessories for the same room, we are going to use a page view controller to display the rest of the view controllers.

Bear in mind that the view controllers can be different. Information about a door that can be open or closed is not retrieved in the same manner as the aquarium temperature is received. However, every accessory has some common parts like the device name, the service, and the characteristic. This is the reason why each view controller must inherit from AccessoryViewController.

GarageDoorViewController

Now, we are going to implement our first visible accessory view controller. Here, we will need to use two images to represent the...