Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my app freeze when I make a POST request with NSURLRequest?
    text
    copied!<p>I have a method like this. It works fine when my device is connected through wifi network, but when it is connected through 3G network it freezes my app for some seconds. So, because it is an interactive app, when it does some various post request it must continuing running so the user can continue to use the app. Any solution for this ?</p> <p>I tried reducing the [theRequest setTimeoutInterval:2.0]; but that didn't fix my problem.</p> <pre><code>// post request - (void)postRequestWithURL:(NSString *)url body:(NSString *)body contentType:(NSString *)contentType options:(NSDictionary *)dict { // set request NSURL *requestURL = [NSURL URLWithString:url]; NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc] init]; if([dict count] &gt; 0) { for (id key in dict) { NSLog(@"[theRequest addValue:%@ forHTTPHeaderField:%@]", [dict valueForKey:key], key); [theRequest addValue:[dict valueForKey:key] forHTTPHeaderField:key]; } } if (contentType != nil) { [theRequest addValue:contentType forHTTPHeaderField:@"Content-type"]; } [theRequest setURL:requestURL]; [theRequest setTimeoutInterval:2.0]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:[body dataUsingEncoding:NSASCIIStringEncoding]]; [self.oauthAuthentication authorizeRequest:theRequest]; // make request //responseData = [NSURLConnection sendSynchronousRequest:theRequest // returningResponse:&amp;response // error:&amp;error]; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES]; self.web = conn; [conn release]; NSLog(@"########## REQUEST URL: %@", url); // request and response sending and returning objects } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload