Problem in NSURLConnection didFailWithError: method in iPhone SDK
I am using NSURLconection method to post the data to the Server. If the request failed due to the Low Wi-FI connectivity.... I am getting alert due to
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
UIAlertView* statusAlert3 = [[UIAlertView alloc] initWithTitle:@"Alert"
message:@"Error in communicating to server. We regret the inconvenience. Please try again."delegate:self
开发者_Go百科 cancelButtonTitle: @"Ok"
otherButtonTitles:nil];
[statusAlert3 show];
[statusAlert3 release];
}
When the request is failed I am getting this alert twice at the same time. when I cancel this, i am again getting this alert for Once.
Can AnyOne help me in this regard. thanks in Advance.
There can be multiple reasons:
- There can be multiple connection in the object context so delegate is calling for different connection objects --- Are you sure that there is only one active NSURLConnection for the time?
- There can be some different UIAlertView which is getting called.
My suggestion:
- Keep a brake point in the didFailWithError: delegate -- make sure how many call back is getting called
- If there is multiple call backs are getting called --- check what are the connection object responsible for it.
As per my knowledge didFailWithError: will not be called multiple times for the same connection.
精彩评论