Search code examples
iphonembprogresshud

How to chain several actions using MBProgressHUD?


Basically I have 3 steps:

  1. I need to prepare the data to be sent to the server. This takes some time.
  2. After preparing the data, I have to send it to the server - this also takes a while.
  3. I wait for the response from server that everything is OK.

I was thinking of using MBProgressHUD for each of these actions - I show hud, and use the showWhileExecuting method. Then when I hide hud in that code I call the next action, and show hud again.

In theory this should work, but is this the way this should be done?


Solution

  • It would be better to not depend on MBProgressHUD. You should use it as a feedback element for the user, not as an operation manager.

    You could use a NSOperationQueue, for example, and just notify the hud to update its data/status in each iteration.

    Of course, you could use it like you said, but does not seems clean to me (programatically).