I am trying to get a distance from my longitude and latitude i have stored into core data, to the current location. I have this code, but i cannot figure out how to integrate the code for using the coordinates i have stored in core data. How do i use my coordinates stored in core data to get distance from user location? Thank you for any help!
CLLocation *to = [[CLLocation alloc]
initWithLatitude:mapView.userLocation.coordinate.latitude
longitude:mapView.userLocation.coordinate.longitude];
CLLocation *from = [[CLLocation alloc]
initWithLatitude:mapView.userLocation.coordinate.latitude
longitude:mapView.userLocation.coordinate.longitude];
CLLocationDistance distance = [to distanceFromLocation:from];
_distance.text = [[NSString alloc]initWithFormat:@"%g",distance];
I get my core data coordinates like this:
_buyLong.text = [[_itemDetailArray valueForKey:@"longitude"] description];
_buyLatitude.text = [[_itemDetailArray valueForKey:@"latitude"] description];