Chapter 7. Plot Buddy – All about Location

Naturally, one of the most important features of mobile devices is their ability to find their own location, whether using GPS sensors or cell data tower locations, or whatever. The Apple Watch is quite capable of capturing location data, either using the iPhone's GPS or when the iPhone is not present, translating its accelerometer data into location data. A pretty neat trick, from a development perspective, and one which enables the user to leave the phone where it is and take off with just the watch.

In developing this app, we will look at several new aspects of programming with the WatchKit framework, as well as a couple of techniques that apply equally to watchOS and iOS development. They include the following topics:

  • Property Lists
  • Core Location framework
  • Protocols
  • Adding an init method
  • Forcing named arguments

Planning the app

Although we will be using some pretty advance programming for this app, the actual use scenario is quite straightforward and our user story will be simply structured.

Mission Statement

Plot Buddy will enable the user to store any number of locations directly from the watch; while moving around, say, a plot of land, or a regular jogging route, or any number of situations in which a list of related location data would be useful. When the user is finished, it will be possible to send the data to the paired iPhone (once it is in range), from where it could be used in any number of ways.

User Story

After launching the app, the user will be offered a single active button with the title Start Plotting, which will allow him to start plotting locations.

Once plotting has started, a second button, titled Add Current Coordinates, will become active which will trigger the addition of the current location's geo-coordinates to a list that is maintained by the app. The location coordinates, assuming the location is found, will be displayed on screen (or an error notification if no location data is retrieved). The Start Plotting button will now have the title Stop Plotting.

This will continue until he stops plotting at which point he will see a button, titled Show Plots. This will offer the chance to inspect all the plots he has stored in the current list presented in a table on a new screen.

Each item in the table will display the number of the location in the list as well its latitude and longitude values.

From the main screen, a Force Touch will display a menu that will enable the user to send all the current data to the iPhone app.

..................Content has been hidden....................

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