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 (17 chapters)
Building Apple Watch Projects
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Testing with the iPhone and real data


We are now ready to test entering user data into the iOS app (which should work without issues—you downloaded it from the website, after all) and to test the transfer of that data to the watchOS app.

If you have already run the iPhone app and tested what the buttons do (we're developers, we're naturally curious, OF COURSE you've played around with it), then you will already have sent some default data to the Watch. Let's get rid of that first by deleting the app from the iOS Simulator.

Now we're all starting from the same point.

Unstub the WatchDataManagerinit method

Although we have stored prompts data to NSUserDefaults in the updatePrompts method, we still have a dataManager that returns stubbed data, so let's fix that now. Replace the init of the current WatchDataManager implementation with the following code:

private init(){
    if let storedPrompts = NSUserDefaults.standardUserDefaults().objectForKey(kPromptsKey) as! [Prompt]? {
            self.prompts...