Search code examples
iphoneasynchronousrequestasihttprequest

Is the ASIHTTPRequest is not asynchronous?


I am using ASIHTTPRequest to fetch some data from a web service.

I am making requests using a loop.

The problem is that it doesn't seem the request is going asynchronously so that my activityindicator is not working .

Is it true that ASIHTTPRequest is not asynchronous .

or should i use the regular nsmutablerequest to perform asynchronous request .


Solution

  • You should put your request in a download queue, i.e.

    ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(requestDone:)];
    [request setDidFailSelector:@selector(requestWentWrong:)];
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    [queue addOperation:request];
    [request release];    
    

    Just

    [request startAsynchronous]; 
    

    runs the request on the UI thread, so you should try it with download queue.