In this episode, we continue with the simple app. We add a map and set up a push segue to get to it.

This is a multi-part video tutorial series, so be sure to subscribe to the newsletter to be notified when the next episode releases.

Video Tutorial

Finished Project

or see it on GitHub

Relevant code

    let location = CLLocationCoordinate2D(latitude: 37, longitude: -122)
    let coordinateSpan = MKCoordinateSpan(latitudeDelta: 10, longitudeDelta: 10)
    mapObject.addAnnotation(location, withPinColor: .Purple)
    mapObject.setRegion(MKCoordinateRegion(center: location, span: coordinateSpan))

Tutorial Steps

  1. Drag an interface controller from the object library to the storyboard.

  2. Add a map object onto it.

  3. Drag a button onto the original controller.

  4. Control-drag from the button to the new controller and select 'push'.

  5. Create a new interface controller file in the WatchKit Extension.

  6. Add code for a location with latitude and longitude.

  7. Add code for a coordinate span to set the zoom level.

  8. Add a colored pin.

  9. Finally set the map's region with the location and coordinate span.

  10. Build and run the app to see it in the iOS Simulator for Apple Watch. 

Hello WatchKit Series