kumar123
kumar123

Reputation: 889

Concurrent task in AFNetworking

Currently I am running 3 task concurrently using AFNetworking.But my problem is that I need to refresh tableview once all the above three task complete.But as in AFNetworking all the operation are async. So any operation can finish first. I am not getting a point where I need to refresh my tableview. I am planning to do some critical section type implementation.Is there can other way to accomplish the above.

Upvotes: 1

Views: 238

Answers (2)

mattt
mattt

Reputation: 19544

Use the built-in batched request operation feature of AFNetworking. The completion handler for the batch would include the logic to refresh your data source once all of the operations have finished.

Upvotes: 5

Maarten
Maarten

Reputation: 351

Maybe having some sort of 'active requests array' is a solution for you.

  • Every time you make a request, add it to the (mutable) array.
  • When the request finishes, remove it from the array.
  • Every time a request finishes, check the array length (count).
  • If your array has become empty again, all request have been finished and you can reload your tableview.

Upvotes: 2

Related Questions