Doug Tabuchi
Doug Tabuchi

Reputation: 308

What is the best way in RestKit to send off two requests then do a action only after both return?

I have a number of API calls I need to send off and then want to do something only when they all return, like [SVProgressHUD dismiss];

What is the best way to do that?

Upvotes: 0

Views: 221

Answers (2)

Wain
Wain

Reputation: 119031

It depends how you're making the requests, but RKObjectManager offers a number of options:

The RKObjectManager gives you access to the operationQueue on which the requests are running so you can check the operationCount.

The RKObjectManager also lets you enqueueBatchOfObjectRequestOperations:... with a progress and a completion callback.

Yet more, the RKObjectManager also lets you search for pending requests using enqueuedObjectRequestOperationsWithMethod:....

Upvotes: 1

David Hoerl
David Hoerl

Reputation: 41642

Create a mutable NSArray and add some identifier to it when you send the request, and delete it when you get a response, and when the array is empty you are done.

Upvotes: 0

Related Questions