2011-03-08 2 views
6

iOS 4.3 (GM Seed 10M2518) 이후 MKReverseGeocoder을 사용할 때 충돌이 발생합니다. reverseGeocoder:didFailWithError:은 꽤 자주이 같은 오류와 함께 호출됩니다 :iOS 4.3에서 MKReverseGeocoder/PBHTTPStatusCode = 503 오류를 처리하는 방법은 무엇입니까?

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

응용이 순간에 충돌하는 경향이있다. 이전 버전의 iOS에서는 그렇지 않습니다.

어떤 아이디어가 있었습니까?

답변

5

는 실패에 조기 역 지오 코더를 공개하지 않습니다 있는지 확인하십시오 :

[_reverseGeocoder release] 변경

-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error에서 [_reverseGeocode autorelease]에 나를 위해 문제를 해결. 내 MKReverseGeocoder 코드는 애플의 예제 중 하나를 따라 비록 처음에는 같은 문제가 있었다 -(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error

_reverseGeocoder.delegate = nil; 
[_reverseGeocoder autorelease]; 
+0

에서 지오 코더 개체를 해제하지 않았지만 여전히 didFailWithError에서 수행합니다. 이유를 설명 할 수 있습니다 .http : //stackoverflow.com/questions/7443252/at-first-time-mkreversegeocoder-didfailwitherrorer-domain-nsurlerrordomain -c – Srinivas

+0

여기에 있습니다 .. 모든 솔루션 ?? 감사합니다 – Frade

+0

너무 많이 호출해야합니다 http://stackoverflow.com/questions/2941495/mkreversegeocoder-server-returned-error-503 –

2

여기에도 같은 문제가 있으며 여러 가지 해결책을 확인했지만 작동하지 않았습니다. 503 응답 코드는 이전 OS에서 다르게 처리되므로 iPhone 트래픽을 스니핑하여 쉽게 알 수 있습니다.

Gowalla와 같은 MKReverseGeocoder를 사용하는 응용 프로그램은 Apple에 대한 압력을 줄 것입니다 ... 요즘에는 4.3.1 핫픽스가 나올 것으로 예상됩니다. 또는 Google이 Apple의 요청에 따라 SLA를 변경합니다.

1

이 zippo77의 대답에 이어, 내가 가장 좋은 결과를 발견 (MKReverseGeocoder 글로벌 autorelease 변수). 또한이 문제는 iOS 4.3에서만 나타났습니다 (4.0은 문제가 없었습니다). 나를 autorelease 부분을 제거하고보기 만의 dealocMKReverseGeocoder을 발표했다에 대한 문제를 해결 무엇

.

1

에서 전무로 MKReverseGeocoder 대리자를 설정할 때

4

Google에서는 단일 기기가 60 초 이내에 한 번만 위치를 검색하도록 허용하지 않으므로 (MKReverseGeocoder *) 지오 코더 didFailWithError 일 때 다른 메소드 (http 요청 대신 JSON이 필요함)로 작업합니다.

4.3.3 (3GS)에서 작동하며 사용자의 위치를 ​​충돌없이 연속적으로 검색하는 30-40 회의 테스트를 거쳤습니다. 도움이 되었기를 바랍니다.

- (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"]; 
    } 
} 
+0

그래서 패키지 된 MKReverseGeocoded가 ' 일하지 마라. 이상한 해결책이 아닙니까? 처음에 명시 적 요청을 한 경우 코드가 더 복잡해집니다. –

1

위치 코더가 위치 표시를 찾으려면 먼저 위치 관리자를 중지해야합니다. didFindPlacemark에서 또는 오류

관련 문제