简体   繁体   中英

URLSessionTaskDelegate - delay between 100% progress and didCompleteWithError call

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!

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%.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM