2

I'm developing a location based app and I'm using the following code (which works perfectly) to retrieve the location of the user. However, I would like to set a default value to the longitude and latitude in case the user turned off location services.

I tried self.latitude = 0; but the app crashes. latitude and longitude are variables of type float. Ideally I want to set them to a default value of (0,0).

So basically: how can I set a default value for a variable of type float?

Thanks for your help.

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation    *)newLocation fromLocation:(CLLocation *)oldLocation
{
    self.latitude = newLocation.coordinate.latitude;
    self.longitude = newLocation.coordinate.longitude;
    SVGeocoder *geocodeRequest = [[SVGeocoder alloc] initWithCoordinate:newLocation.coordinate];
    [geocodeRequest setDelegate:self];
    [geocodeRequest startAsynchronous];
    //   NSLog(@"lat:%f,long:%f",self.latitude,self.longitude);

    [self.locationMgr stopUpdatingLocation];
}

0 Answers0