Apple Watch Concepts

apple_watch

Architecture

app_communication_2x

Apple Watch

  • Resides on the Apple watch

  • Contains storyboard, resource files and no program code

WatchKit Extension

  • Resides on the user’s iPhone

  • Contains code for managing interface

User Interaction

  • Apple Watch is not functional without a paired iPhone.

  • The Watch OS looks for an appropriate storyboard scene to display.

  • Operating system tells the user’s iPhone to launch the extension and load interface.

  • The interface controller configures the elements and transitions of each scene.

Interface Styles

Hierarchical

  • Select an item displays more information.

  • Always starts with a single root interface controller.

  • Use pushControllerWithName:context to pass data to next controller

Page-Based

  • Fixed number of independent interface controllers.

  • User navigates by swiping left or right on screen.

  • System initializes all interface elements at runtime.

Life Cycle

  • The user’s iPhone automatically launches your WatchKit extension on launch.

  • Messages flow transparently between the app and extension until user interaction stops.

  • The WatchKit framework calls its initWithContext: method.

  • Design your controllers to be lightweight and never perform long-running tasks.

Launch Watch App

watch_app_lifecycle_simple_2x

Any Questions?

facebookbtn   twitterbtn

Build a Watch App

WatchKit_01

Install Xcode 6.2

Architecture

  • Your Apple Watch is the view, contains user interface resources and controls user input.

  • Your iPhone contains the controller/model, responds to events and taps.

WatchKit_03

Create New Project

  • File > New Project… > Single View Application

  • Name your project WatchApp.

  • Leave everything as default.

Screen Shot 2014-11-21 at 5.22.09 PM

Create Apple Watch

File > New > Target…

Screen Shot 2014-11-21 at 5.27.21 PM

Storyboard

  • Open the Interface.storyboard file.

  • Drag a Map object onto the Interface Controller.

  • Declare an WKInterfaceMap outlet property in InterfaceController class.

  • Connect it to your Map object in Storyboard.

 Handle Coordinates

  • Create additional properties for setting default location of the map.Screen Shot 2014-11-22 at 1.18.52 AM

Display Buttons

  • Drag two WKInterfaceButton objects to your Storyboard.

  • The user will zoom to a location using buttons.

Screen Shot 2014-11-22 at 1.28.14 AM

Zoom Functions

  • Code the actions to control the location.

  • Connect the buttons to their respective methods.

Screen Shot 2014-11-22 at 1.26.49 AM

setMapToCoordinate

  • Create the method to set the region and coordinates of the map.

Screen Shot 2014-11-22 at 1.33.55 AM

Initial Zoom Level

Screen Shot 2014-11-22 at 2.59.31 AM

Build & Run

Voila! Test out your new creation. Screen Shot 2014-11-22 at 3.07.25 AM

Any Questions?

facebookbtntwitterbtn