Book Image

Building Apple Watch Projects

By : Stuart Grimshaw
Book Image

Building Apple Watch Projects

By: Stuart Grimshaw

Overview of this book

With Apple’s eagerly anticipated entry into the wearable arena, the field is wide open for a new era of app development. The Apple Watch is one of the most important technologies of our time. This easy-to-understand book takes beginners on a delightful journey of discovering the features available to the developer, right up to the completion of medium-level projects ready for App Store submission. It provides the fastest way to develop real-world apps for the Apple Watch by teaching you the concepts of Watch UI, visual haptic and audio, message and data exchange between watch and phone, Web communication, and finally Visual, haptic as well as audio feedback for users. By the end of this book, you will have developed at least four fully functioning apps for deployment on watchOS 2.
Table of Contents (12 chapters)
11
Index

Implementing the methods


Take a deep breath, we don't run the code for a while!

We will start with our InterfaceController class. This is where the user's engagement with the app begins, and this is where we will begin to endow the classes with life.

When the app launches, it automatically loads the view that is designated as the Main Entry Point, identified in Interface Builder by the Main arrow, as shown in the following figure:

In our case, this main entry point is the InterfaceController class.

The InterfaceController class

In addition to performing duties of its own, InterfaceController creates two objects on which it must call. Firstly, an instance of our GameLogic class and secondly, an instance of NSTimer with which we will control the timing of the flashing colors.

In contrast to some languages, in Swift we can both declare these properties and instantiate them at the same time. Add the following code to the InterfaceController class below the IBOutlet declaration:

    @IBOutlet var greenGroup...