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! :-)
let distance = fromLocation.distanceFromLocation(toLocation)
New syntax:
let distance = aLocation.distance(from: anotherLocation)
func distanceFromLocation(_ location: CLLocation!) -> CLLocationDistance
Returns the distance (in meters) from the receiver’s location to the specified location.
Read more here https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/index.html#//apple_ref/occ/instm/CLLocation/distanceFromLocation:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With