Tuesday, 20 August 2013

How to return variable from this method?

How to return variable from this method?

I need to return the longitude and latitude from this method. This is from
the locationManager code. When I log the lat, longt they give the correct
values.
What I have been unable to do is to work out you to export/return the
variables out of this method. How should I go about changing it?
- (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];
}

No comments:

Post a Comment