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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:14:42+00:00 2026-05-24T19:14:42+00:00

I am writing a web-connected application that needs to execute several asynchronous requests to

  • 0

I am writing a web-connected application that needs to execute several asynchronous requests to load data needed lower down in the dependency tree.

Fig 1.


For visualization purposes, consider an example with ASIHTTPRequests A,B,C,D,E, and F:

A’s url depends on the result of B and C,

and B’s url depends on the result of D, E, and F.

B and C can be computed concurrently, and so can D, E, and F.

NSOperationQueue = [(D,E,F),(B,C),A]


Thus far, I have created an NSOperationQueue that contains a dependency tree of ASIHTTPRequests. However, the URLs of the ASIHTTPRequests should depend on the results of the previous operations, and, right now, they do not.

The question: What is the best way to pass the results of the computations performed by multiple NSOperations to the NSOperation that depends on them, and how can I set this up with ASIHTTPRequests?

Thanks in advance,
Julian Ceipek

  • 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-24T19:14:43+00:00Added an answer on May 24, 2026 at 7:14 pm

    I ended up solving this problem by wrapping the ASIHTTPRequest in a custom NSOperation object that populated the request in such a way that custom request B contained a pointer to an object in D, E, and F’s ASIHTTPRequest UserInfo Dictionary. While I liked @JosephH’s solution, I couldn’t figure out how to easily generate a dictionary or array with dependency tree intact.

    A simplified version of my custom NSOperationObject is provided below; any suggestions are welcome. I used Apple’s Concurrency Programming Guide extensively as a reference, but as I have not had any prior experience extending the NSOperation class, I am sure that there is a better way to do this.

    #import <Foundation/Foundation.h>
    #import "SyncableData.h"
    #import "ASIHTTPRequest.h"
    
    @interface PushContentRequest : NSOperation <ASIHTTPRequestDelegate> {
        BOOL executing;
        BOOL finished;
        id <SyncableData> data;
        ASIHTTPRequest *request;
        NSURL *url;
        id <ASIHTTPRequestDelegate> delegate;
    }
    
    - (id)initWithDataObject:(id <SyncableData>)theData url:(NSURL *)theUrl delegate:(id <ASIHTTPRequestDelegate>)theDelegate;
    
    @end
    
    
    #import "PushContentRequest.h"
    
    @implementation PushContentRequest
    
    - (id)initWithDataObject:(id <SyncableData>)theData url:(NSURL *)theUrl delegate:(id <ASIHTTPRequestDelegate>)theDelegate {
        if ((self = [super init])) {
            executing = NO;
            finished = NO;
            data = [theData retain];
            url = [theUrl retain];
            delegate = [theDelegate retain];
        }
        return self;
    }
    
    - (BOOL)isConcurrent {
        return YES;
    }
    
    - (BOOL)isExecuting {
        return executing;
    }
    
    - (BOOL)isFinished {
        return finished;
    }
    
    - (void)start {
        if ([self isCancelled]) {
            [self willChangeValueForKey:@"isFinished"];
            finished = YES;
            [self didChangeValueForKey:@"isFinished"];
            return;
        }
    
        NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
        request = [ASIHTTPRequest requestWithURL:url];
        NSString *xmlToPost = [[NSString alloc] initWithString: [theData getXMLRep]];
        [request appendPostData:[xmlToPost dataUsingEncoding:NSUTF8StringEncoding]];
        [request setDelegate:self];
        NSDictionary *userInfoDict = [[NSDictionary alloc] initWithObjectsAndKeys:data, @"theData", nil];
        [request setUserInfo:userInfoDict];
        [userInfoDict release];
        [xmlToPost release];
        [self willChangeValueForKey:@"isExecuting"];
        [request start];
        executing = YES;
        [self didChangeValueForKey:@"isExecuting"];
        [pool release];
    
    }
    
    - (void)dealloc {
        [delegate release];
        [url release];
        [data release];
        [super dealloc];
    }
    
    - (void)requestFinished:(ASIHTTPRequest *)therequest {
        [delegate requestFinished:therequest];
    
        [self willChangeValueForKey:@"isFinished"];
        [self willChangeValueForKey:@"isExecuting"];
    
        executing = NO;
        finished = YES;
    
        [self didChangeValueForKey:@"isExecuting"];
        [self didChangeValueForKey:@"isFinished"];
    }
    
    - (void)requestFailed:(ASIHTTPRequest *)therequest {
        [delegate requestFailed:therequest];
        [self willChangeValueForKey:@"isFinished"];
        [self willChangeValueForKey:@"isExecuting"];
    
        executing = NO;
        finished = YES;
    
        [self didChangeValueForKey:@"isExecuting"];
        [self didChangeValueForKey:@"isFinished"];
    }
    
    @end
    

    The delegate of this PushContentRequest currently handles the interpretation of the ASIHTTPRequest’s UserInfo Dictionary and the request in my implementation, though I suppose that it might make more sense to do this processing within the PushContentRequest’s body.

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

Sidebar

Related Questions

I am writing a web application that requires user interaction via email. I'm curious
I'm writing a web application that decodes Morse Code that is tapped in using
I'm writing my first C# web application that connects to an XML based service.
I'm writing web application where I need to push data from server to the
I've been writing a Web Application recently that interacts with iPhones. The iPhone iphone
I'm writing a PHP-based web application that should work with multiple database systems. The
I'm writing a web application to generate labels. The label printer that I'm targeting
Several frameworks for writing web-based desktop-like applications have recently appeared. E.g. SproutCore and Cappuccino
I writing a web site that uses Active Directory to validate users. I don't
I'm writing a web service, and I want to return the data as XHTML.

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.