Reputation: 3291
I am working on map kit and i have task to change location in mapkit using UILongPressGestureRecognizer
class, i always successfully get latitude and longitude but i couldn't get location some time. I am doing like this.
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleGesture:)];
lpgr.minimumPressDuration = 2.0; //user must press for 2 seconds
[mapView addGestureRecognizer:lpgr];
[lpgr release];
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer
{
MKPointAnnotation *pa = [[MKPointAnnotation alloc] init];
pa.coordinate = touchMapCoordinate;
temp.latitude= pa.coordinate.latitude;
temp.longitude= pa.coordinate.longitude;
MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:pa.coordinate];
reverseGeocoder.delegate = self;
[reverseGeocoder start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
temp.location = ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO);
NSLog(@"original location is %@",temp.location);
}
But some time i got error like this
/SourceCache/ProtocolBuffer/ProtocolBuffer-92/Runtime/PBRequester.m:687 server returned error: 503 2012-01-02 16:19:36.284 openInvite[303:707] reverseGeocoder: didFailWithError:Error Domain=NSURLErrorDomain Code=-1011 "The operation couldn’t be completed. (NSURLErrorDomain error -1011.)" UserInfo=0x124ea0 {PBHTTPStatusCode=503}
Please help me on that.
Upvotes: 2
Views: 1541
Reputation: 5568
The HTTP Status Code is the clue.
503 Service Unavailable
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.
Note: The existence of the 503 status code does not imply that a server must use it when becoming overloaded. Some servers may wish to simply refuse the connection.
So check the HTTP Status code and if its 503 send the Request again. This should fix the problem
Upvotes: 1