Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:07:25+00:00 2026-05-27T08:07:25+00:00

I have a method like this. It works fine when my device is connected

  • 0

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 ?

I tried reducing the [theRequest setTimeoutInterval:2.0]; but that didn’t fix my problem.

// 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] > 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:&response 
        //                                               error:&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
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:07:25+00:00Added an answer on May 27, 2026 at 8:07 am

    It’s freezing your app because you have told it to. You have passed YES into startImmediately. This means that it will start the connection on that thread and wait until it’s finished. I guess the thread you’re doing this on will be the main thread – the one that also handles the ui etc 🙂

    You need to use something like connectionWithRequest:delegate: – this will run the request in the background and tell you when it’s done.

    PS The reason you didn’t spot the bug in wifi is because the data was sent so fast you couldn’t notice the pause in your app 🙂

    PPS The reason the timeout didn’t fix it is because the request wasn’t timing out – it was just getting data very slowly 🙂


    EDIT

    Something like this :

    self.web = [NSURLConnection connectionWithRequest:request delegate:self];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a code like this i have defined the method goNext but still
I have an Event Handler that overrides the ItemAdded method. This works fine on
I have some code like this: Object doMethod(Method m, Object... args) throws Exception {
Assume we have a method like this: public IEnumerable<T> FirstMethod() { var entities =
If I have a method like this: public void DoSomething(int Count, string[] Lines) {
In a multithreaded scenario, I have a method like this: bool WaitForChange( time_duration WaitTime
I have a method that looks like this: public static String escape(String text) {
I have a javascript method looks like this JSMethod(JS_para_1,JS_para_2) { ...... ,,,,, } and
I have a method on an interface that looks like this and I want
I have a method in a url rewriting module that looks like this public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.