current location alway 00000.00, 00000.00

35 views Asked by At

I am trying to get my current location and the reverseGeoCode it for an address but I keep getting my location as long 00000.00 and lat 00000.00 Here is my code

locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.distanceFilter = kCLDistanceFilterNone;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
    CLGeocoder *ceo = [[CLGeocoder alloc]init];
    currentLocation = [[CLLocation alloc]initWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude]; //insert your coordinates
    NSLog(@"loc:%@",currentLocation);
    [ceo reverseGeocodeLocation:currentLocation
              completionHandler:^(NSArray *placemarks, NSError *error) {
                  CLPlacemark *placemark = [placemarks objectAtIndex:0];
                  if (placemark) {
                     
                      NSString *strString =placemark.name;
                      NSLog(@"strString:%@",strString);
                      NSString *midstring = [strString stringByAppendingString:@","];
                      if (placemark.postalCode == nil) {
                          self->postalcodeString = @"00000";
                      }
                      else{
                          self->postalcodeString = placemark.postalCode;
                      }
                      
                      self->combineString = [midstring stringByAppendingString:self->postalcodeString];
                      NSLog(@"combineString:%@",self.combineString);
                  }
0

There are 0 answers