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 8014891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:05:04+00:00 2026-06-04T20:05:04+00:00

I do a lot of request to the server: NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL

  • 0

I do a lot of request to the server:

    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
    [theRequest setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; 

     urlData = [[NSMutableData data] retain];
    urlConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES];

    if (urlConnection) 
    {
        finishedLoading = FALSE;
        while(!finishedLoading) {
            [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
        }
    }
    else 
    {
        [delegate swHttpConnection:self withRequest:urlString failedWithError:nil];
    }

…When the request is done, I get a callback. However, If I use the code below, the selector won’t get called:

- (void)request:(MBRequest *)request finished:(NSMutableArray *)resultArray
{
    //Handle resultArray data 

    [self performSelector:@selector(someRandomFunction) withObject: nil afterDelay:1.0f]; 
}

..but if I use the code below; It works fine:

- (void)request:(MBRequest *)request finished:(NSMutableArray *)resultArray
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND,0), ^(void) 
    {
        dispatch_async(dispatch_get_main_queue(), ^(void) 
        {
            //Handle resultArray data 

            [self performSelector:@selector(someRandomFunction) withObject: nil afterDelay:1.0f]; 
        }); 
    }); 
}

So my question is twofold.

  1. Is this the right way to do it? Do I need to force the callback to be run on the mainthred, or is the logic of the code wrong?

  2. If I do have to force the callback to be ran on the mainthred, is the code above correct?

Also, the server request code crash sometimes at the:

[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];

And I get this warning somethings:

Class _NSZombie_NSRunLoop is implemented in both ?? and ?? 

Thanks in advance

  • 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-06-04T20:05:06+00:00Added an answer on June 4, 2026 at 8:05 pm

    As you update the UI in this segment

      dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND,0), ^(void) 
        {
            dispatch_async(dispatch_get_main_queue(), ^(void) 
            {
                //Handle resultArray data 
    
                [self performSelector:@selector(someRandomFunction) withObject: nil afterDelay:1.0f]; 
            }); 
        }); 
    

    then it has to be called in the UI thread then yes you have to do it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Auto-binding of request params seems like default behaviour, but I can't find a lot
I need to update a lot of rows, per a user request. It is
I am sending some request on a server and it's reply me this: {COLUMNS:[REGISTRATION_DT,USERNAME,PASSWORD,FNAME,LNAME,EMAIL,MOBILE,FACEBOOK_ID],DATA:[[March,
I'm designing some client-server web project with a lot of requests and responses. So
In SL4 application I perform a lot of requests (30) to the server in
In educational purposes I'm writing a HTTP server in C++. When receiving a request,
Looking through my server logs, I see that a lot of pages on my
I have an application which upon start request around 10-12KB of data from server
I write a web site with jquery and lot of ajax request to get
I'm getting this error The remote server returned an unexpected response: (400) Bad Request..

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.