Search code examples
iosdownloadkey-value-observinguiprogressbar

Keep track of download progress UI independantly


I'm working on a magazine app(without newsstand kit) for iOS. There are 3 magazines and each magazine has 3 issues. My main view controller represent Magazine shelf, and magazine button will navigate to the their issue shelf(view controller) when user interacts.

My problem is when downloading the issues, users may want to go back to the Magazine shelf. So in this case I lose my issueCover view class(where cover image, download button, progress bar lies in) and lost connection between issueCover view and Download Client class.

I was trying to get progress from Download Client Class using KVO State Observing but since users can navigate, my KVO sending progress to the empty view and then leads to crash.

What I do is the almost same with this tutorial app except magazine issue cover can be nil

How can I keep track of this download progress float numbers even if view has disappeared and reappear?


Solution

  • You should to encapsulate download method and variables to one object and hold it with magazine shelf view. When you modal magazine cover view you needed to assign magazine shelf view to class variable that make you able to track the download progress.