Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Handling Multiple Asynchronous Requests: Send a Signal When All Requests Are Finished

So I am browsing over Stack Overflow for ways to handle asynchronous requests effectively. Right now I am using ASIHTTPRequest and my application consumes a REST API, in which a request to a single resource prompts me to request 5 or more additional resources (linked resources).

Right now I am doing all asynchronous request inside one huge method, there may be around 6 asynchronous request each with their setCompletionBlock and setFailBlock. If you have used ASIHTTPRequest, you must have an idea of how much repetitive code that will take.

Anyway, I seem to have found a solution to determine if all requests are finished with this answer: Multiple asynchronous URL requests

however, I don't know how to apply that answer in code ,as I have not used push notifications before and I have always used "self" as delegats and never other classes.

Any ideas how I can apply the answer to code or better yet, do you know of any other methods?

Thanks in advance!

like image 368
yretuta Avatar asked Sep 19 '11 23:09

yretuta


Video Answer


1 Answers

Put all the requests into an ASINetworkQueue: http://allseeing-i.com/ASIHTTPRequest/How-to-use#about_ASINetworkQueues.

ASINetworkQueue has a callback called "queueDidFinishSelector".

like image 119
Michael Frederick Avatar answered Oct 26 '22 06:10

Michael Frederick