at first time MKReverseGeocoder: didFailWithError:Error Domain=NSURLErrorDomain Code=-1011 {PBHTTPStatusCode=503}

微笑、不失礼 提交于 2019-12-01 12:50:00

问题


In my application at first time reverseGeocoder results like error block below :

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

This is the code I used:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { 

     geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];
     [geocoder setDelegate:self];
     [geocoder start];
    [locationManager stopUpdatingLocation];
}   
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder1 didFailWithError:(NSError *)error
{
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"iBeen There" message:@"GPS can't track the location please check the internet connection." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    NSLog(@"reverseGeocoder:%@ didFailWithError:%@", geocoder, error);
}

The first time its going to error block (some times). Am I missing any thing please help me out?


回答1:


Error -1011 is Bad Server Response (from the apple docs here) and the HTTP status code is 503 (Service Unavailable).

So, I guess that unless you're giving them invalid data, it's a problem their end!

However, there are a few edge cases that you might consider checking :

(1) What's the value of coordinate? If it's invalid then the geocoder probably returns some sort of error (though it probably shouldn't return 503 ;)

(2) Are you behind a proxy / web authentication - if you are then you're not actually talking to a geocoding service, you're talking to a proxy which probably won't understand what you're trying to do!



来源:https://stackoverflow.com/questions/7443252/at-first-time-mkreversegeocoder-didfailwitherrorerror-domain-nsurlerrordomain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!