Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Apple Watch Projects

You're reading from  Building Apple Watch Projects

Product type Book
Published in Feb 2016
Publisher Packt
ISBN-13 9781785887369
Pages 298 pages
Edition 1st Edition
Languages
Author (1):
Stuart Grimshaw Stuart Grimshaw
Profile icon Stuart Grimshaw

Table of Contents (17) Chapters

Building Apple Watch Projects
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Exploring the New Platform 2. Hello Watch 3. C-Quence – A Memory Game 4. Expanding on C-Quence 5. On Q – A Productivity App 6. Watching the Weather 7. Plot Buddy – All about Location 8. Images, Animation, and Sound 9. Wear It, Test It, Tweak It, Ship It 10. This Is Only the Beginning Index

Data structure


Firstly, we define a typealias for the data structure added to both the watch and the phone targets, that will hold the location data, by following these steps:

Shared constants

In the downloaded project, create a new Swift file, name it SharedConstants.swift, being sure to select both targets, Plot Buddy and Plot Buddy WatchKit Extension, as illustrated here:

Select this file in the project navigator and replace the import statement with the following code:

Import WatchKit

typealias LocationSet = [CLLocation] //1

let ApplicationContextDataKey = "Data" //2
  1. Our LocationSet data structure is nothing more than an array of CLLocation objects, which is the type returned by our calls to the Core Location framework.

  2. For the sake of safety, we define a String constant for use as the Key to the data object passed from watch to phone in the ApplicationContext.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}