# NSURLSession documentation

Software documentation for the NSURLSession class
Foundation/NSURLSession.h
NSURLSession is a replacement API for NSURLConnection. It provides options that affect the policy of, and various aspects of the mechanism by which NSURLRequest objects are retrieved from the network.
An NSURLSession may be bound to a delegate object. The delegate is invoked for certain events during the lifetime of a session. NSURLSession instances are threadsafe. An NSURLSession creates NSURLSessionTask objects which represent the action of a resource being loaded. NSURLSessionTask objects are always created in a suspended state and must be sent the -resume message before they will execute. Subclasses of NSURLSessionTask are used to syntactically differentiate between data and file downloads. An NSURLSessionDataTask receives the resource as a series of calls to the URLSession:dataTask:didReceiveData: delegate method. This is type of task most commonly associated with retrieving objects for immediate parsing by the consumer.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
sessionWithConfiguration:
configuration
delegate:
delegate
delegateQueue:
queue
Description forthcoming.
configuration
Description forthcoming.
dataTaskWithRequest:
request
Description forthcoming.
dataTaskWithURL:
url
Description forthcoming.
delegate
Description forthcoming.
delegateQueue
Description forthcoming.
downloadTaskWithRequest:
request
Description forthcoming.
downloadTaskWithURL:
url
Description forthcoming.
finishTasksAndInvalidate
Description forthcoming.
invalidateAndCancel
Description forthcoming.
sessionDescription
Description forthcoming.
setSessionDescription:
sessionDescription
Description forthcoming.
Software documentation for the NSURLSessionConfiguration class
Foundation/NSURLSession.h
NSCopying
Description forthcoming.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
HTTPAdditionalHeaders
Description forthcoming.
HTTPCookieAcceptPolicy
Description forthcoming.
HTTPCookieStorage
Description forthcoming.
HTTPMaximumConnectionLifetime
Description forthcoming.
HTTPMaximumConnectionsPerHost
Description forthcoming.
HTTPShouldSetCookies
Description forthcoming.
HTTPShouldUsePipelining
Description forthcoming.
URLCache
Description forthcoming.
URLCredentialStorage
Description forthcoming.
configureRequest:
request
Description forthcoming.
protocolClasses
Description forthcoming.
requestCachePolicy
Description forthcoming.
setHTTPAdditionalHeaders:
headers
Description forthcoming.
setHTTPCookieAcceptPolicy:
policy
Description forthcoming.
setHTTPCookieStorage:
storage
Description forthcoming.
setHTTPMaximumConnectionLifetime:
n
Permits a session to be configured so that older connections are reused. A value of zero or less uses the default behavior where connections are reused as long as they are not older than 118 seconds, which is reasonable for the vast majority if situations.
setHTTPMaximumConnectionsPerHost:
n
Description forthcoming.
setHTTPShouldSetCookies:
flag
Description forthcoming.
setHTTPShouldUsePipelining:
flag
Description forthcoming.
setRequestCachePolicy:
policy
Description forthcoming.
setURLCache:
cache
Description forthcoming.
setURLCredentialStorage:
storage
Description forthcoming.
Software documentation for the NSURLSessionDataTask class
Foundation/NSURLSession.h
Description forthcoming.
Software documentation for the NSURLSessionDownloadTask class
Foundation/NSURLSession.h
Description forthcoming.
Software documentation for the NSURLSessionStreamTask class
Foundation/NSURLSession.h
Description forthcoming.
Software documentation for the NSURLSessionTask class
Foundation/NSURLSession.h
NSCopying
Description forthcoming.
number of byte bytes we expect to receive, usually derived from the Content-Length header of an HTTP response.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
number of body bytes we expect to send, derived from the Content-Length of the HTTP request
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
number of body bytes already received
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
number of body bytes already sent
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
The request this task is currently handling. This may differ from originalRequest due to http server redirection
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
The error, if any, delivered via -URLSession:task:didCompleteWithError: This is `nil` until an error has occured.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
The request this task was created to handle.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
The response to the current request, which may be `nil` if no response has been received
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
The current state of the task within the session.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
a description of the current task for diagnostic purposes
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
An identifier for this task, assigned by and unique to the owning session
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
The dispatch queue used to handle this request/response. This is actualy a libdispatch queue of type dispatch_queue_t, but on all known implementations this is a pointer, so void* is the correct size.
Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.
cancel
Description forthcoming.
countOfBytesExpectedToReceive
Description forthcoming.
countOfBytesExpectedToSend
Description forthcoming.
countOfBytesReceived
Description forthcoming.
countOfBytesSent
Description forthcoming.
currentRequest
Description forthcoming.
error
Description forthcoming.
originalRequest
Description forthcoming.
response
Description forthcoming.
resume
Description forthcoming.
session
Description forthcoming.
setResponse:
response
Description forthcoming.
setTaskDescription:
taskDescription
Description forthcoming.
state
Description forthcoming.
suspend
Description forthcoming.
taskDescription
Description forthcoming.
taskIdentifier
Description forthcoming.
Software documentation for the NSURLSessionUploadTask class
Foundation/NSURLSession.h
Description forthcoming.
Software documentation for the NSURLSessionDataDelegate protocol
Foundation/NSURLSession.h
NSURLSessionTaskDelegate
Description forthcoming.
URLSession:
session
dataTask:
dataTask
didReceiveData:
data
Description forthcoming.
URLSession:
session
dataTask:
dataTask
didReceiveResponse:
response
completionHandler:
completionHandler
Informs the delegate of a response. This message is sent when all the response headers have arrived, before the body of the response arrives.
Software documentation for the NSURLSessionDelegate protocol
Foundation/NSURLSession.h
NSObject
Description forthcoming.
URLSession:
session
didBecomeInvalidWithError:
error
Description forthcoming.
URLSession:
session
didReceiveChallenge:
challenge
completionHandler:
handler
Description forthcoming.
Software documentation for the NSURLSessionDownloadDelegate protocol
Foundation/NSURLSession.h
NSURLSessionTaskDelegate
Description forthcoming.
URLSession:
session
downloadTask:
downloadTask
didFinishDownloadingToURL:
location
Description forthcoming.
URLSession:
session
downloadTask:
downloadTask
didResumeAtOffset:
fileOffset
expectedTotalBytes:
expectedTotalBytes
Description forthcoming.
URLSession:
session
downloadTask:
downloadTask
didWriteData:
bytesWritten
totalBytesWritten:
totalBytesWritten
totalBytesExpectedToWrite:
totalBytesExpectedToWrite
Description forthcoming.
Software documentation for the NSURLSessionTaskDelegate protocol
Foundation/NSURLSession.h
NSURLSessionDelegate
Description forthcoming.
URLSession:
session
task:
task
didCompleteWithError:
error
Description forthcoming.
URLSession:
session
task:
task
didReceiveChallenge:
challenge
completionHandler:
handler
Description forthcoming.
URLSession:
session
task:
task
didSendBodyData:
bytesSent
totalBytesSent:
totalBytesSent
totalBytesExpectedToSend:
totalBytesExpectedToSend
Description forthcoming.
URLSession:
session
task:
task
willPerformHTTPRedirection:
response
newRequest:
request
completionHandler:
completionHandler
Description forthcoming.