views:

35

answers:

1

"Forced" to use sendSynchronousRequest (POST) for our application. Checking if "response" is nil (below) will catch a few of the connection errors that may occur, but I'd like to invoke a timer as well to cancel the request after about 20 s. Not sure on how to do that and how to "wait" for time out. Any suggestions? Thanks in advance.

  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];

    } ...   
A: 

try this:

request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
Reena
Thanks, but this does not work (also according to other posts on this issue).
Dan
what is the problem?
Reena
The timeoutInterval is not taken in account when using the POST method, has a fixed standard value (more than 1 minute)
Dan