-1

URLSessionTaskDelegate has two methods - didSendBodyData that called every upload progress update, and didCompleteWithError that called at the end of the file transfer.

The problem is that didSendBodyData reaches 100%, and only 2-3 seconds after didCompleteWithError called with success.

This means I have a loader or a progress bar, and only 2-3 seconds after it reaches 100% I can show something on the screen. It is frustrating.

Anybody knows what is the solution here?

Note: Already made sure I update the UI on the main thread.

Thanks!

Avi Tsadok
  • 1,843
  • 13
  • 19

1 Answers1

0

I would think that is very easy. Your task takes 100% from start to finish. Your task is downloading, plus whatever happens after that. Assign 90% to downloading, and 10% to other things. So your progress goes up to 90%, stays there for two or three seconds, then jumps to 100%.

gnasher729
  • 51,477
  • 5
  • 75
  • 98
  • Thanks for the answer - Maybe I didn't understand you. The situation is that it goes up to 100%, stay there for 2 seconds and only then report completion. Why do I have these 2 seconds delay? – Avi Tsadok Apr 05 '20 at 09:54