How to deal with MKReverseGeocoder / PBHTTPStatusCode = 503 errors in iOS 4.3?

Since iOS 4.3 (GM Seed 10M2518), I am getting crashes when using MKReverseGeocoder . reverseGeocoder:didFailWithError: often reverseGeocoder:didFailWithError: with an error:

Error Domain=NSURLErrorDomain Code=-1011 "The operation couldn't be completed. (NSURLErrorDomain error -1011.)" UserInfo=0x339900 {PBHTTPStatusCode=503}

The app tends to crash at these points. This was not in previous versions of iOS.

Any ideas what happened?

+6
ios mkreversegeocoder
source share
6 answers

Make sure you don't release the reverse geocoder prematurely on failure:

Changing [_reverseGeocoder release] to [_reverseGeocode autorelease] to -(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error fixed the problem for me.

+5
source

Google does not allow one device to get its location more than once in 60 seconds, so it works with another method (an HTTP request, JSON is required instead) when (MKReverseGeocoder *) the geocoder made a FileWithError.

It works for me on 4.3.3 (3GS) and has been tested for 30-40 times, getting the user's location without failures, hope this helps!

 - (void) retrieveCurrentLoc { self.geoCoder = [[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate] autorelease]; geoCoder.delegate = self; [geoCoder start]; } - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{ NSString *fetchURL = [NSString stringWithFormat:@"http://maps.google.com/maps/geo? q=%@,%@&output=json&sensor=true", [NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.latitude], [NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.longitude]]; NSURL *url = [NSURL URLWithString:fetchURL]; NSString *htmlData = [NSString stringWithContentsOfURL:url]; SBJsonParser *parser = [[SBJsonParser alloc] init]; NSDictionary *json = [parser objectWithString:htmlData error:nil]; NSArray *placemark = [json objectForKey:@"Placemark"]; if ([[[[[placemark objectAtIndex:0] objectForKey:@"AddressDetails"]objectForKey:@"Country"]objectForKey:@"Thoroughfare"]objectFor Key:@"ThoroughfareName"] != NULL){ currentAddress = [[[[[placemark objectAtIndex:0] objectForKey:@"AddressDetails"]objectForKey:@"Country"]objectForKey:@"Thoroughfare"]objectFor Key:@"ThoroughfareName"];} else { currentAddress = [[placemark objectAtIndex:0] objectForKey:@"address"]; } } 
+4
source

Same problem here, we checked various solutions and did not work. The 503 response code is handled differently by the previous OS, you can easily notice that sniffing iPhone traffic.

Applications that rely on MKReverseGeocoder (e.g. Gowalla) will put some pressure on Apple ... so I expect Patch 4.3.1 to come in these days. Or Google will change its SLA with Apple requests.

+2
source

Following zippo77's answer, I found the best results when setting the MKReverseGeocoder delegate to nil first in -(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error

 _reverseGeocoder.delegate = nil; [_reverseGeocoder autorelease]; 
+1
source

I had the same problem, although my MKReverseGeocoder code followed one of Apple's examples ( MKReverseGeocoder as a global variable autorelease ). Also, the problem appeared only on iOS 4.3 (4.0 had no problems).

For me, the problem was to remove the autorelease part and release MKReverseGeocoder only in the dealoc view.

+1
source

You will probably stop the location manager before the geocoder finds the tag. Do it in didFindPlacemark file or error

+1
source

All Articles