Skip to content

Commit

Permalink
[Issue #1322] Fixing implementation of download task delegate callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Sep 17, 2013
1 parent 06cd440 commit e5f2004
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions AFNetworking/AFURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,6 @@ - (void)URLSession:(NSURLSession *)session
}
}
}

dispatch_group_async(self.manager.completionGroup ?: url_session_manager_completion_group(), self.manager.completionQueue ?: dispatch_get_main_queue(), ^{
if (self.completionHandler) {
self.completionHandler(downloadTask.response, fileURL, fileManagerError);
}

[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidFinishNotification object:downloadTask userInfo:userInfo];
});
});
}

Expand Down Expand Up @@ -451,6 +443,13 @@ - (NSURLSessionDownloadTask *)downloadTaskWithTask:(NSURLSessionDownloadTask *)d
completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler
{
AFURLSessionManagerTaskDelegate *delegate = [AFURLSessionManagerTaskDelegate delegateForManager:self completionHandler:completionHandler];
delegate.downloadTaskDidFinishDownloading = ^ NSURL * (NSURLSession *session, NSURLSessionDownloadTask *task, NSURL *location) {
if (destination) {
return destination(location, task.response);
}

return location;
};

if (progress) {
*progress = delegate.downloadProgress;
Expand Down

0 comments on commit e5f2004

Please sign in to comment.