Sunday, 18 August 2013

Extracting the NSStrings from this method

Extracting the NSStrings from this method

I am using LocationManager to give the the current Long/Lats and they work
perfectly. The routine is:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation
*)oldLocation {
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
self.lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees,
minutes, seconds];
NSLog(@"Current Latitude : %@",self.lat);
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
self.longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees,
minutes, seconds];
NSLog(@"Current Longitude : %@",self.longt);
[manager stopUpdatingLocation];
}
However I want to be able to return lat,longt so I can use them elsewhere,
rather than just read them in the logs. I haven't been able to work out
how to change this method to achieve this?

No comments:

Post a Comment