$29
School of Electrical Engineering and Computer Science
CptS 479 Mobile Application Development
Homework 9
General Instructions: Put the entire app directory into one zip file and submit as an attachment
under Content → Assignments → Homework 9 for this course on Blackboard Learn by the above
deadline. Note that you may submit multiple times, but only the most recent entry submitted before
the above deadline will be graded.
This homework will be a standalone version of our HealthApp that maintains the user’s total
distance traveled, tracks the user on a map, and continually updates information about the nearest
hospital. See screenshots below. Specifically,
1. Create a new Xcode project called HealthApp that has a single view embedded in a
navigation controller with title “Distance Traveled” and prompt “Health App”. The main
view should have a “Start” button in the upper left and a “Stop” button in the upper right.
Below that should be three labels: “Distance Traveled”, “Nearest Hospital”, and
“Distance”. And the remaining part of the view below the labels should be occupied by a
Map Kit View.
2. When first run, the app should request location when-in-use authorization for which you
may assume “Allow While Using App” will be selected.
3. Tapping the Start button (assuming location services are enabled) should start location
updates with the map tracking the current location. Each time didUpdateLocation is called,
the app should compute the distance from the current location to the last updated location
and add that distance to the “Distance Traveled” value. Also, each time didUpdateLocation
is called, the app should use a MKLocalSearch request on query “hospital” to find the
nearest hospital, display its name in the “Nearest Hospital” label and its distance in meters
in the “Distance” label, and add it to the map as an annotation (after removing any existing
annotation). If this information is unavailable (e.g., the request results in an error or no map
items), then a question mark “?” should be display for the nearest hospital name and
distance value.
4. Tapping the Stop button should stop updating the location and remove the tracking “dot”
from the map. The nearest hospital information can remain.
5. The app should be responsive to changes in the device settings that disable location
services. In particular, if the Start button is tapped, but location services are disabled, a
“Location Services Disabled” alert (see screenshot) should appear. If the location was
2
updating before you disabled location services, location updates should be turned off when
you re-enter the app.
6. Test your app using the iPhone 11 simulator, which is the same simulator we will use to
grade your app.
7. Be sure that auto layout constraints are set so that all view elements are appropriately
displayed with no overlap or trimming regardless of device orientation.
Simulator:
3