I need to perform some network calls. I am using NSURLConnection but I’ve encapsulated that into a new class that uses blocks:
[MAURLConnection asyncConnectionWithURLString:str
completionBlock:^(NSData *data, NSURLResponse *response) {
//completed, do something with data returned
}
errorBlock:^(NSError *error) {
//error
}];
}
But, now I need to call several of these at once, but I need to know when they all finish. What’s the best way to do this? I don’t necessarily need the progress, just when they all have finished.
Simplest think I can think of is a counter. When each connection finishes just increase a counter. Once counter has reached your number you’re done. You can also increase counter thru some function and run notification when counter number is hit.
Variation of this might be array where you could also store some additional info about finished connection.