In the delegate method below, distance is of type Float:
How do I convert distance into meters so that I can find out exactly how far the peers are from one another?
Code Block func session(_ session: NISession, didUpdate nearbyObjects: [NINearbyObject]) { guard let object = nearbyObjects.first else { return } guard let distance = object.distance else { return } print("distance is of type Float but I need to convert to meters: ", distance) }
How do I convert distance into meters so that I can find out exactly how far the peers are from one another?
I got the answer from here:
The distance is a Float type whose value is measured in meters:
Code Block func session(_ session: NISession, didUpdate nearbyObjects: [NINearbyObject]) { guard let object = nearbyObjects.first else { return } guard let distance = object.distance else { return } let meters = String(format: "%.2f m", distance) print("meters: ", meters) }