开发者

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:

  1. 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?
  2. There can be some different UIAlertView which is getting called.

My suggestion:

  1. Keep a brake point in the didFailWithError: delegate -- make sure how many call back is getting called
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜