The code:
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([[[NSUserDefaults standardUserDefaults] objectForKey:@"lat"] floatValue], [[[NSUserDefaults standardUserDefaults] objectForKey:@"lon"] floatValue]);
CLLocation *currentLocation = [[CLLocation alloc] initWithCoordinate:coordinate altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
[objects enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([self.photos[idx][@"lat"] floatValue], [self.photos[idx][@"lon"] floatValue]);
CLLocation *location = [[CLLocation alloc] initWithCoordinate:coordinate altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
CLLocationDistance distance = [location distanceFromLocation:currentLocation]/1000;
}];
If I NSLog the currentLocation and the location I get the same coordinate, because the are the same with minor differences. The locations are: lat: 37.331581 lon: -122.030708 and the current location are: "lat": "37.33154", "lon": "-122.0307". As you can see if I get the distance from these two locations, I should get 0 km. But I am getting 12781.989811. Why is that? I am running the simulator. If that's the case, or my codes are wrong?