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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:40:07+00:00 2026-06-17T05:40:07+00:00

I use fast enumeration and in the enumeration block I send network requests asynchronously.

  • 0

I use fast enumeration and in the enumeration block I send network requests asynchronously.

So what happens is the enumerateObjectsUsingBlock: just call the block super fast and let the enumeration block finish after some time.

This leads to different results, because some requests finish faster than other. So it’s not sorted as I wanted.

Is there any way to set the block to freeze, and after the asynchronous network requests is completed, to just tell it to go to the next one?

Here is some code

    NSArray *sites = [self.fetchedResultsController.fetchedObjects copy];
    NSLog(@"sites - %@",sites);
    [sites enumerateObjectsUsingBlock:^(Sites *site, NSUInteger idx, BOOL *stop) {
        NSLog(@"site name - %@,",site.name);

        [[Wrapper sharedWrapper] sendRequestTo:site completionBlock:{

                NSLog(@"site name - %@",site.name);
        }];
    }];

Thanks!

  • 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-17T05:40:08+00:00Added an answer on June 17, 2026 at 5:40 am

    Is there any way to set the block to freeze, and after the asynchronous network requests is completed, to just tell it to go to the next one?

    You can achieve that result by reorganizing your code: instead of using enumeration, just execute the async request from the completion block, one at the time:

    - (void) doRequestAsync:(NSArray*)sites index:(NSUInteger)index {
    
        if (index >= [sites count]) return;
    
        NSString* site = [sites objectAtIndex:index];
        [[Wrapper sharedWrapper] sendRequestTo:site completionBlock:{
                NSLog(@"site name - %@",site.name);
                [self doRequestAsync:sites index:++index];
        }];
    
    }
    

    Alternatives to this are modifying your Wrapper class so that it uses async networking (but use it on a secondary thread, then, to avoid blocking the UI).

    Or you might implement the Async Completion Token pattern so to be able to reorder the responses when they are received.

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

Sidebar

Related Questions

I am trying to use fast enumeration to print all songs that are in
I thought that I knew how to use fast enumeration, but there is something
Is it possible to use fast enumeration with an NSArray that contains an NSDictionary?
Things to take into consideration: - easy to use - fast - use underlying
Background: I use rails g scaffold hotel name stars:integer to start fast (and insert
I've read I should use money , but in todays fast paced world maybe
The cassandra database seems to be very fast, now I wanted to use it
Sometimes in order to make our application more responsive and fast, we use client
I've already looked at questions git rebase and git push: non-fast forward, why use?
I want to know which one is stable, fast and easy to use?

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.