Saturday 15 May 2010

ios - How to wait for all asynchronously tasks? -


I download some objects from asynchronous, I store it in array. For each object I download some coordinates with geocoding (this is also asynchronous), and update my parameter with the new parameter for each object, which is coordinate. My method looks like this:

  - (zero) Download objects with title: (NSString *) title and handler: (Zero (^) (NSMutableDictionary * result) handler {AFHTTPClient * httpClient = [[AFHTTPClient alloc] InitWithBaseURL: url]; NSMutableURLRequest * Request = [httpClient Request With Method: @ "GET" Path: Zero Parameter: Zero]; AFHTTPRequestOperation * Operation = [[AFHTTPRequestOperation alloc] initWithRequest: Request]; [HttpClient Register HTTPOperationClass: [FHTPPRQuest Operation Class]]; [Operation Set Endogenation Block: Successful: ^ (FHTPPKAEASTECTION * Operation, ID Response Object) {// I get the array of objects here / now for every object, I want to download geocoding localization, so I found another asynchronous method, : Andhandler; For {int i = 0; i & lt; resutArray.count; i ++} {{self download location: string: [objectForKey: @ "string"] and handler: ^ (NSMutableDictionary * result) {// update database ; }]; } Handler (dictionary); } Failure: ^ (FHTPPKAESTA Operation * Operation, NSERR * error) {NSLog (@ "error:% @", error); }]; [Start operation]; }   

My question is how do download coordinates for each object and fire:

  handler (dictionary);   

Then wait for the download (each object) to download each coordinate before the method (fire handler).

Thanx for all the conveniences.

Keep count of all tasks when it's zero, you've already done it.

No comments:

Post a Comment