CLLocation distanceFromLocation (in Swift?)

Proteus picture Proteus · Aug 12, 2014 · Viewed 9.6k times · Source

Can somebody please help me convert the following Objective-C statement to Swift?

CLLocationDistance distance = [fromLocation distanceFromLocation:toLocation];

I know that it must be simple to do that. I am brand new to iOS programming and any help will be greatly appreciated.

Thank you! :-)

Answer

Mundi picture Mundi · Aug 12, 2014
let distance = fromLocation.distanceFromLocation(toLocation)

New syntax:

let distance = aLocation.distance(from: anotherLocation)