0

I am uplading a a file to Parse as the documentation suggests.

[imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

} progressBlock:^(int percentDone) {
// Update your progress spinner here. percentDone will be between 0 and 100.
HUD.progress = (float)percentDone/100;
}]

The progressblock is called like 100 times where i update the HUd which seems to be ok.The problem is that the completion block is called like 10 seconds later when the progress block is called for the last time with the value 100.

As a result the hud remains on the screen with 100 % and removed 10 seconds later when the completion block is called.

I doubt that the progress block is called independent of the upload process by estimation.

P.S The file i am uploading is like 2.35 MB.

Ilker Baltaci
  • 11,644
  • 6
  • 63
  • 79

2 Answers2

0

Try HUD.progress = (float)percentDone/100.0;

Verdant
  • 288
  • 1
  • 10
  • it is not about the hud it self.it is about the delay when block is called with 100 and the completion block is called after a delay. – Ilker Baltaci Nov 26 '14 at 09:43
-1

There is possibly a delay between the client app completing the upload and the Parse server completing processing of the upload and sending a response confirming successful save. I do not believe there is a way to determine the progress of this processing, however you could try decreasing the progress shown to allow this. For example:

HUD.progress = (float)percentDone*0.9/100;

This way it will increment to 90% and display that until the Parse server returns. Or you could check for percentDone == 100 and display some other message like "Processing...".

JoGoFo
  • 1,928
  • 14
  • 31
  • it can be done but it does not solve the problem.what if the delay is longer than 10 seconds. – Ilker Baltaci Nov 26 '14 at 09:44
  • Extensive delays could be suggestive of network issues, which is beyond your control for end users. If the upload fails, you should be handling this by checking the NSError. If you are concerned about UI feedback you maybe could trigger a timer at 100% which checks for completion of the upload, and provides some kind of message if the Parse server has not yet returned. – JoGoFo Nov 26 '14 at 10:45