Hi,
In one of my iPhone application I am using NSURLConnection class to connect to the web server. Following code use to work fine on iPhone SDK 2.1 but when I upgraded my iPhone SDK to 3.0 its stopped working.
After call to sendSynchronousRequest method application hangs for a minute in case of wrong url but if url is valid application is working fine.
Here is the code
NSMutableURLRequest *theRequest=[[NSMutableURLRequest alloc] init];
/* Set Requests post data and method */
[theRequest setURL:[NSURL URLWithString:urlAddress]];
[theRequest setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
[theRequest setTimeoutInterval:3];
theRequest.HTTPMethod = @"POST";
theRequest.HTTPBody = [command dataUsingEncoding:NSASCIIStringEncoding];
[theRequest setValue: @"text/xml" forHTTPHeaderField
"Content-Type"];
/* create the connection with the request and start loading the data */
NSURLResponse *response;
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
Even though I am setting timeout interval to 3 seconds its not responding at all.
Can anyone help with problem or suggest an alternative way to download data from url synchronously.
Thanks,
Paresh
In one of my iPhone application I am using NSURLConnection class to connect to the web server. Following code use to work fine on iPhone SDK 2.1 but when I upgraded my iPhone SDK to 3.0 its stopped working.
After call to sendSynchronousRequest method application hangs for a minute in case of wrong url but if url is valid application is working fine.
Here is the code
NSMutableURLRequest *theRequest=[[NSMutableURLRequest alloc] init];
/* Set Requests post data and method */
[theRequest setURL:[NSURL URLWithString:urlAddress]];
[theRequest setCachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData];
[theRequest setTimeoutInterval:3];
theRequest.HTTPMethod = @"POST";
theRequest.HTTPBody = [command dataUsingEncoding:NSASCIIStringEncoding];
[theRequest setValue: @"text/xml" forHTTPHeaderField
/* create the connection with the request and start loading the data */
NSURLResponse *response;
NSError *error;
NSData *data = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
Even though I am setting timeout interval to 3 seconds its not responding at all.
Can anyone help with problem or suggest an alternative way to download data from url synchronously.
Thanks,
Paresh