O'Reilly logo

Building Apple Watch Projects by Stuart Grimshaw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Interface Controllers

With the PBLocationManager in place, we have done the heavy lifting of the app. The interface controllers are very slim in design and simple in implementation.

Create the InterfaceController class

Select the InterfaceController.swift file that was created as part of the Xcode template and replace all of the code in it (including the import statement) with the following:

Import WatchKit class InterfaceController: WKInterfaceController, PBLocationManagerDelegate { var locationManager: PBLocationManager! //1 override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) locationManager = PBLocationManager(delegate: self) //2 locationManager.requestLocation() //3 } func handleNewLocation(newLocation: CLLocation) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required