views:

184

answers:

1

Hi, i have the next code:

NSURL *url = [NSURL URLWithString:@"http:...."];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [""soapMessage"" length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [""soapMessage"" dataUsingEncoding:NSUTF8StringEncoding]];
[theRequest setTimeoutInterval:20];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
[theConnection start];

Then sometimes, when i click a lot of times (Just to try where can fail the app) in my interface in the buttons assigned to start a new connection, the connection doesn't give a reply (I send the request but looks like is blocked after).

I would like to know what is the use of "setTimeoutInterval"? AND if there are some ways to limit the time to wait one response?

Thanks!

A: 

How do you know that the request started in the first place? You might be waiting for a response for a request that never started.

It appears you are not testing for theConnection being set to nil. also theRequest and url could also be nil if you run out of memory.

corydoras
Thank you, but i make log of each part, and i sended it.ANYWAY there are some method to LIMIT the time?
The logging was not in the code you pasted so there was no way to tell that you were logging for these things from your code.
corydoras