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

Setting up the project


Set up a new project using the iOS App with WatchKit App template that we have used before, but this time include the Glance Scene (and deselect Notification Scene as previously), as pictured here:

Requirements

Using the flow diagram to provide some (very welcome) visual support, we can now start to think about our requirements in more concrete terms.

Weather data structure

Since we'll be passing a number of weather summaries to the table view that displays the initial view of the data, it makes sense to be able to package the data necessary for each individual summary into some sort of structure.

Create a new Swift file, call it WeatherData.swift, and select both the WatchKit app and the iOS app targets, as pictured here:

Note

Why do we select the phone app target when we are writing an app that will function exclusively on the watch? Well, this is simply some prudent future-proofing of the app. It seems likely that we will expand the app at some point in the future to provide...