Skip to content

Instantly share code, notes, and snippets.

@floriankugler
Last active September 29, 2023 15:56
Show Gist options
  • Save floriankugler/6870499 to your computer and use it in GitHub Desktop.
Save floriankugler/6870499 to your computer and use it in GitHub Desktop.
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| NSURLSessionTaskDelegate URLSession:task:didReceiveChallenge:completionHandler:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willCacheResponse: | NSURLSessionDataDelegate URLSession:dataTask:willCacheResponse:completionHandler:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:didFailWithError: | NSURLSessionTaskDelegate URLSession:task:didCompleteWithError:
NSURLConnectionDataDelegate connectionDidFinishLoading: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDataDelegate connection:willSendRequest:redirectResponse: | NSURLSessionTaskDelegate URLSession:willPerformHTTPRedirection:newRequest:completionHandler:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDataDelegate connection:didReceiveResponse: | NSURLSessionDataDelegate URLSession:dataTask:didReceiveResponse:completionHandler:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDataDelegate connection:didReceiveData: | NSURLSessionDataDelegate URLSession:dataTask:didReceiveData:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDataDelegate connection:needNewBodyStream: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDataDelegate connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDownloadDelegate connection:didWriteData:totalBytesWritten:expectedTotalBytes: | NSURLSessionTaskDelegate URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDownloadDelegate connectionDidResumeDownloading:totalBytesWritten:expectedTotalBytes: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDownloadDelegate connectionDidFinishDownloading:destinationURL: | NSURLSessionDownloadDelegate URLSession:downloadTask:didFinishDownloadingToURL:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
| NSURLSessionDelegate URLSession:didBecomeInvalidWithError:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
| NSURLSessionDataDelegate URLSession:dataTask:didBecomeDownloadTask:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
| NSURLSessionDataDelegate URLSessionDidFinishEventsForBackgroundURLSession:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
| NSURLSessionDownloadDelegate URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
| NSURLSessionDownloadDelegate URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:
@timcolla
Copy link

Still helping developers in 2018!

@zihanzzz
Copy link

awesome to see this! thanks.

@coderChrisLee
Copy link

Thanks a lot.

@wving5
Copy link

wving5 commented Mar 1, 2019

Good job, thx.
connection:didWriteData:totalBytesWritten:expectedTotalBytes: matching URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:, is it an unintentional mistake ?

@Deniffer
Copy link

Thinks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment