Data structure

Firstly, we define a typealias for the data structure added to both the watch and the phone targets, that will hold the location data, by following these steps:

Shared constants

In the downloaded project, create a new Swift file, name it SharedConstants.swift, being sure to select both targets, Plot Buddy and Plot Buddy WatchKit Extension, as illustrated here:

Shared constants

Select this file in the project navigator and replace the import statement with the following code:

Import WatchKit

typealias LocationSet = [CLLocation] //1

let ApplicationContextDataKey = "Data" //2
  1. Our LocationSet data structure is nothing more than an array of CLLocation objects, which is the type returned by our calls to the Core Location framework.
  2. For the sake of safety, we define a String constant for use as the Key to the data object passed from watch to phone in the ApplicationContext.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.239.214