Search code examples
iosswiftswift2core-motion

how to convert no of steps in pedometer to distance in miles in iOS?


I am getting no of steps from core-motion
i need to get distance in miles from that step count

let convertedDistance = self.distance / 1609.344
let roundedDistanceinMiles = String(format: "%.2f", convertedDistance)

Solution

  • You can use the distance property from the CMPedometerData which gives you the distance in meters that way you don't need to convert the steps.