Inspiration

I enjoy distance running and have recently joined a challenge group to run (at least) 2018 miles between January 1, 2018 and December 31, 2018. I needed an app to help me keep track of my current cumulative distance and to let me know how far off track I am after taking a few days off running.

What it does

RunTargets keeps track of the running and walking distance measured by your iPhone. It calculates the total distance as well as the daily average and how far ahead/behind you are with respect to your specified target. If you are behind target, it calculates how many miles (or km) you need to run or walk daily to get back on track. It also displays a handy graph of your daily distances.

How I built it

I wrote the app in Objective-C. It uses the Apple HealthKit framework to obtain the daily running and walking distances as well as the workout data stored in the phone.

Challenges I ran into

Determining when to run the HealthKit statistics query was a challenge since the query can take some time to execute (>10 seconds during testing). At first, I thought I would put it in the Target Details screen since that is where the totals and averages are displayed. But since since it can take a while, I decided it should be executed immediately upon app launch instead. This prevents me from having to display a loading screen when the user enters the Target Details screen, but it does add complexity to the code since the task executes in the background and posts a notification once it is done.

Accomplishments that I'm proud of

I designed and developed this app entirely on my own. It took longer than expected since I am not a designer, but I am pleased overall with how it came out.

What I learned

I learned a lot about HealthKit since this was my first time using that framework. I also learned how to execute a long running task in a background thread and notify the rest of the app once that task is complete.

What's next for RunTargets

I plan on adding more functionality such as the ability to add workouts manually, support for other activity types (currently it is just running and walking), achievements, and probably some user interface improvements.

Built With

Share this project:

Updates