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) { //3 print(newLocation) } func handleLocationFailure(error: NSError) { //4 print(error) } }
What we are doing here is writing the bare minimum code necessary to test...