The problem is that you are calling the object method :
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location;
class CLLocation.
CLLocationCoordinate2D is actually a two-locale structure:
typedef struct { CLLocationDegrees latitude; CLLocationDegrees longitude; } CLLocationCoordinate2D;
The right way to do this is to get the CLLocation object and call distanceFromLocation on it. Like this:
CLLocation* newLocation; CLLocation* oldLocation; CLLocationDistance distance = [newLocation distanceFromLocation:oldLocation];
Of course, first you need to initialize both of these values โโ(for example, from CLLocationManager ).
Pawel Oct 11 2018-10-11 12:03
source share