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.
The HTTP Status Code is the clue.
So check the HTTP Status code and if its 503 send the Request again. This should fix the problem