Guest User

Untitled

a guest
Sep 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. for i in 0..<(dataArray - 1) {
  2. let coordinate1 = CLLocation(latitude: (dataArray[i] as AnyObject).value(forKey: "addressLatitude") as! CLLocationDegrees, longitude: (dataArray[i] as AnyObject).value(forKey: "addressLongitude") as! CLLocationDegrees)
  3. let coordinate2 = CLLocation(latitude: (dataArray[i+1] as AnyObject).value(forKey: "addressLatitude") as! CLLocationDegrees, longitude: (dataArray[i+1] as AnyObject).value(forKey: "addressLongitude") as! CLLocationDegrees)
  4.  
  5. var distance: CLLocationDistance? = nil
  6. distance = coordinate1.distance(from: coordinate2)
  7. let kilometers = CLLocationDistance((distance ?? 0.0) / 1000.0)
  8. print(kilometers)
  9. }
Add Comment
Please, Sign In to add comment