1

I'm downloading an image and would like to present some form of progress for the download:

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:post.url]];
    AFHTTPRequestOperation *imageOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    imageOperation.responseSerializer = [AFImageResponseSerializer serializer];

    [imageOperation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
        NSLog(@"bytesRead: %d, totalBytesRead: %lld, totalBytesExpected: %lld", bytesRead, totalBytesRead, totalBytesExpectedToRead);
    }];

I also have a completion block and [imageOperation start]; after that.

However, if I select an image to download all I ever get logged is:

bytesRead: 72081, totalBytesRead: 72081, totalBytesExpected: 72081

Why is it only giving me the information at the end?

1 Answers1

1

It ended up being due to the fact I had already previously loaded that image, so I assume the OS cached the result. So it only returned 100% progress as it was already downloaded.