[Issue #411] Dispatching upload/download progress blocks to the main queue
This commit is contained in:
parent
84eae9d31e
commit
c9680e1246
2 changed files with 11 additions and 5 deletions
|
|
@ -197,7 +197,9 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
|
|||
/**
|
||||
Sets a callback to be called when an undetermined number of bytes have been uploaded to the server.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times.
|
||||
@param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread.
|
||||
|
||||
@discussion This block is called on the main thread.
|
||||
|
||||
@see setDownloadProgressBlock
|
||||
*/
|
||||
|
|
@ -206,7 +208,7 @@ extern NSString * const AFNetworkingOperationDidFinishNotification;
|
|||
/**
|
||||
Sets a callback to be called when an undetermined number of bytes have been downloaded from the server.
|
||||
|
||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times.
|
||||
@param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread.
|
||||
|
||||
@see setUploadProgressBlock
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -539,7 +539,9 @@ didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
|
|||
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
|
||||
{
|
||||
if (self.uploadProgress) {
|
||||
self.uploadProgress(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.uploadProgress(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -562,7 +564,9 @@ didReceiveResponse:(NSURLResponse *)response
|
|||
}
|
||||
|
||||
if (self.downloadProgress) {
|
||||
self.downloadProgress((long long)[data length], self.totalBytesRead, self.response.expectedContentLength);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.downloadProgress((long long)[data length], self.totalBytesRead, self.response.expectedContentLength);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue