Just a quick question on Core Location, I\'m trying to calculate the distance between two points, code is below:
-(void)locationChange:(CLLocation *)newL
The problem here is that you're calling an object method:
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location;
of class CLLocation.
CLLocationCoordinate2D is in fact a structure, consisting of two doubles:
typedef struct
{
CLLocationDegrees latitude;
CLLocationDegrees longitude;
} CLLocationCoordinate2D;
Proper way of doing this is to get a CLLocation
object and call distanceFromLocation
on it. Like this:
CLLocation* newLocation;
CLLocation* oldLocation;
CLLocationDistance distance = [newLocation distanceFromLocation:oldLocation];
Of course you first need to initialize both of those values (from CLLocationManager
, for instance).