Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

detz

macrumors 65816
Original poster
Jun 29, 2007
1,051
0
CLLocation *test1 = [[CLLocation alloc] initWithLatitude:42.27818011 longitude: -71.39553308];

CLLocation *test2 = [[CLLocation alloc] initWithLatitude:42.27818012 longitude: -71.39553308];

double diff = 0;
diff = [test1 getDistanceFrom:test2];

diff is -347598198. I can't get this to work at all.
 

slycrel

macrumors newbie
Jul 11, 2008
29
0
I am using getDistanceFrom: fairly heavily and I haven't noticed any problems. However, I have been using this with locations passed back to me by locationManager:didUpdateToLocation:fromLocation:, only rarely (when my app is restarted after it has quit) do I use initWithLatitude:, though it seems to work fine there as well. It could be a precision issue, I don't know how far the location manager looks.

Good luck.
 

ulbador

macrumors 68000
Feb 11, 2010
1,554
0
I have a dollar. It says you are doing something like:

NSLog(@"diff: %d",diff);

Print a float instead:

NSLog(@"diff: %.0f",diff);
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.