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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:52:38+00:00 2026-05-26T23:52:38+00:00

How can i incorporate ASIHTTPRequest with Blocks into an GCD Concurrent Queue Currently i

  • 0

How can i incorporate ASIHTTPRequest with Blocks into an GCD Concurrent Queue

Currently i am doing using this way. I don’t want to compare GCD Queues and ASINetworkQueue. Here i am using GCD Queues and want to know is i am doing correct

NSString *urlString = [NSString stringWithFormat:@"http://mysite.com/news_detail/",tagID];  
NSURL *url = [NSURL URLWithString:urlString]; 

__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadCache:[ASIDownloadCache sharedCache]];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request setCachePolicy:ASIAskServerIfModifiedWhenStaleCachePolicy | ASIFallbackToCacheIfLoadFailsCachePolicy];   
[request setDelegate:self];


[request setCompletionBlock:^{

dispatch_queue_t JSONProcessingQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

    dispatch_async(JSONProcessingQueue, ^{


        dispatch_sync(JSONProcessingQueue, ^{
            NSData *responseData = [request responseData];
            [self processData:responseData];
        });


        dispatch_sync(dispatch_get_main_queue(), ^{
            [self DisplayNews];
        });       

    }); 

}];

[request setFailedBlock:^{
    NSError *error = [request error];
    NSLog(@"Error in downloading : %@", error.localizedDescription);
}];

[request startAsynchronous]; 
  • 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-26T23:52:38+00:00Added an answer on May 26, 2026 at 11:52 pm

    I think my answer will help with your issue – Here i am trying to call my ASIHTTP request in a GCD . But Completion block and failed blocks are not executing

    In short – don’t use GCD. use ASINetworkQueue.

    EDIT:

    Jonathan, I wasn’t comparing. Your current solution is just incorrect.

    What you’re doing right now, is starting an asynchronous request, which is an operation performed on a different thread. In the completion/error blocks, which will be performed on the same different thread, you ask for some global queue (i.e. thread), and move all operations to it.

    The problem is that GCD is not magic, just a very successful ambiguation of threading. It assumes that it starts on the main thread, and moves back and forth between threads.

    If you’re really bent on learning the hard way, then here are my thoughts on your usage of GCD:

    I assume you’re trying to get the data, parse it and update the GUI using the DisplayNews method. if so, and also assuming you must use a global queue and not create a queue of your own, This is how you should do it:

        dispatch_async(JSONProcessingQueue, ^{
    
            NSData *responseData = [request responseData];
            [self processData:responseData];
    
            dispatch_sync(dispatch_get_main_queue(), ^{
                [self DisplayNews];
            });       
    
        }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Picture this: you are creating a little module that people can incorporate into their
Is there anyway I can incorporate a pretty large text file (about 700KBs) into
I'm seeking a library, or bit of code I can incorporate into a Cocoa
I am looking for a 3rd party licensing module that can be incorporated into
What am I missing I cant figure it out by the way this is
So I'm using this code to get the last entry for each day from
I am now using this code: - (void)loadLauncher:(NSMutableArray *)categoriesArray { _launcherView = [[TTLauncherView alloc]
How can I take an IntelliJ generated ant build and incorporate my project's unit
I am trying to incorporate a libtool-based package into a project of my own,
I am trying to incorporate some HTML into a silverlight application however even commercial

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.