Merge pull request #825 from OliverLetterer/thread-issue

Fixes -[AFURLConnectionOperation totalBytesRead] threading issue.
This commit is contained in:
Mattt Thompson 2013-02-27 08:36:47 -08:00
commit c3e70f9948

View file

@ -628,18 +628,18 @@ didReceiveResponse:(NSURLResponse *)response
- (void)connection:(NSURLConnection __unused *)connection
didReceiveData:(NSData *)data
{
self.totalBytesRead += [data length];
if ([self.outputStream hasSpaceAvailable]) {
const uint8_t *dataBuffer = (uint8_t *) [data bytes];
[self.outputStream write:&dataBuffer[0] maxLength:[data length]];
}
if (self.downloadProgress) {
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
self.totalBytesRead += [data length];
if (self.downloadProgress) {
self.downloadProgress([data length], self.totalBytesRead, self.response.expectedContentLength);
});
}
}
});
}
- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection {