From the course: Advanced iOS App Development: Core Motion

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Add elapsed tIme

Add elapsed tIme - iOS Tutorial

From the course: Advanced iOS App Development: Core Motion

Start my 1-month free trial

Add elapsed tIme

- [ Voiceover] The Pedometer application so far, cannot measure pace for all devices. We tried using the built in average pace, to the CM Pedometer class, but that didn't work for the iPhone 5s I'm using. Pace, however, is a calculated value, and it's a good example of getting around the lack of device availability. I've got distance on this device, and all I need is time to compute pace on my own. Let's add elapsed time to the app, from that I'll compute an average pace. An easy way to get elapsed time, is to add a counter to the current timer, and display the counter. At the top of the code, add the following two declarations: var elapsed seconds equals 0.0 and let interval equals 0.1 I'll use elapsed seconds as a counter, and interval as an increment. I'll change my timer to use this interval. Slide down to start timer. Change the time interval from 1.0 to interval. In the completion block, add an increment to elapsed seconds. Self.elapsed seconds plus, equals self.interval. With…

Contents