iPhone SDK中的NSURLConnection-didFailWithError:方法中存在问题
我正在使用nsurlconnection方法将数据发布到服务器。如果由于低Wi-FI连接导致请求失败。。。。由于天气原因,我变得警觉起来iPhone SDK中的NSURLConnection-didFailWithError:方法中存在问题,iphone,objective-c,cocoa-touch,Iphone,Objective C,Cocoa Touch,我正在使用nsurlconnection方法将数据发布到服务器。如果由于低Wi-FI连接导致请求失败。。。。由于天气原因,我变得警觉起来 -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { UIAlertView* statusAlert3 = [[UIAlertView alloc] initWithTitle:@"Alert"
-(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
cancelButtonTitle: @"Ok"
otherButtonTitles:nil];
[statusAlert3 show];
[statusAlert3 release];
}
当请求失败时,我会同时收到两次此警报。当我取消此操作时,我再次收到此警报
在这方面有人能帮我吗。提前感谢。可能有多种原因:
据我所知,同一连接不会多次调用didFailWithError:。可能使用错误的localizedDescription设置警报文本将帮助您找到原因。您是否使用NSURLConnection方法在同一视图控制器中将数据发布到服务器两次。