0
“强制”在我们的应用程序中使用sendSynchronousRequest(POST)。检查“响应”是否为零(下面)将捕获可能发生的一些连接错误,但我想调用一个计时器以及约20秒后取消请求。不知道如何做到这一点,以及如何“等待”超时。有什么建议么?提前致谢。iPhone:使用NSMutableURLRequest和NSTimer处理连接超时
data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(response == nil) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Connection error"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
[alert resignFirstResponder];
[alert release];
} ...
谢谢,但这不工作(也可根据在这个问题上其他职位)。 – Dan 2010-07-15 10:10:55
是什么问题? – Reena 2010-07-15 10:35:14
使用POST方法时不会考虑timeoutInterval,具有固定的标准值(超过1分钟) – Dan 2010-07-15 10:50:47