NSURLSession delegate and completionHandler

前端 未结 2 1028
日久生厌
日久生厌 2021-01-05 18:14

I am using NSURLSession + NSURLDownloadTask with completionHandler:

[session downloadTaskWithURL:downloadURL completionHandler:^(NSURL *location, NSURLRespon         


        
2条回答
  •  灰色年华
    2021-01-05 18:30

    To employ the didWriteData method of the NSURLSessionDownloadDelegate, you sadly have to use the rendition of downloadTaskWithURL without the completionHandler and then implement your own URLSession:downloadTask:didFinishDownloadingToURL: to perform those actions you otherwise would have done in the completion handler.

    This is a little annoying (especially since the NSURLSessionDownloadDelegate is set at the session object), but it's how it works.

提交回复
热议问题