Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem setting progress #19

Open
josealonsogarcia opened this issue Sep 12, 2016 · 1 comment
Open

Problem setting progress #19

josealonsogarcia opened this issue Sep 12, 2016 · 1 comment

Comments

@josealonsogarcia
Copy link

josealonsogarcia commented Sep 12, 2016

Hi,

I m trying to set the progress to the stopDownloadButton in a NSURLSessionDownloadTask . I see the stopDownloadButton, but the progress is not increasing. Here is my block:

progress:^(NSProgress * _Nonnull downloadProgress) {
     self.downloadButton.stopDownloadButton.progress = downloadProgress.fractionCompleted;
}                                                                

What am I doing wrong?

Thanks in advance,

@ryanholden8
Copy link
Contributor

Hi, perhaps that callback is not on the main thread? To properly update the UI it must be done on the main thread.

progress:^(NSProgress * _Nonnull downloadProgress) {[weak self] in
    dispatch_async(dispatch_get_main_queue()) {
        self?.downloadButton.stopDownloadButton.progress = downloadProgress.fractionCompleted
    }
}  

(Also good to weak reference self inside a block, to avoid retain cycles)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants