向 CLLocationDistance 添加一些计算

Add some calculation to CLLocationDistance

这是我的问题 我可以在控制台中打印双精度值(又名距离),但我无法使用双精度值并在 table 视图中添加距离,例如。

if previousLocation == nil {
            previousLocation = locations.first
        } else {
            guard let latest = locations.first else { return }
            let distanceInMeters = previousLocation?.distance(from: latest) ?? 0
            print("Distance in meters: \(distanceInMeters)")
            guard var unwrappedPaceNumber = paceNumber.first else { return }
            
            let total = unwrappedPaceNumber += "\(distanceInMeters)"
            paceNumber[0] = "\(total)"
            tableView.reloadData()
            
            previousLocation = latest
        }

我终于变成那样了 如果这可以帮助

 if previousLocation == nil {
            previousLocation = locations.first
        } else {
            guard let latest = locations.first else { return }
            let distanceInMeters = previousLocation?.distance(from: latest) ?? 0
            var distanceRounded = distanceInMeters.rounded()
            print("Distance in meters: \(distanceRounded)")
            let unwrappedPaceNumber = paceNumber[0]
            distanceRounded += Double(unwrappedPaceNumber)!
            paceNumber[0] = "\(distanceRounded)"
            print(paceNumber[0])
            tableView.reloadData()

            previousLocation = latest
        }