Downloading large files with AFNetworking

前端 未结 2 533
误落风尘
误落风尘 2021-02-04 20:50

I\'m trying to implement downloading of a large file and show to user current progress, but block in:

-[AFURLConnectionOperation setDownloadProgressBlock:] 
         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-04 21:43

    I have no problems with the setDownloadProgressBlock in AFNetworking.

    The wiki explains how to track download progress: https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ

    For progress tracking you don't need the bytesRead (number of bytes written in a particular callback).

    Example code:

    [downloadoperation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
            float progress = ((float)totalBytesRead) / totalBytesExpectedToRead;
            self.progressView.progress = progress;
        }];
    

提交回复
热议问题