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.
Customization of NSURLSession occurs during
creation of a new session. If you do specify a
delegate, the delegate will be
retained until after the delegate has
been sent the URLSession:didBecomeInvalidWithError:
message.
The configuration object used to create the session. A
copy of the configuration object is made. Changes to
the configuration object after the session is created
have no effect.
-finishTasksAndInvalidate
returns immediately and existing tasks will be
allowed to run to completion. New tasks may not be
created. The session will continue to make
delegate callbacks until
URLSession:didBecomeInvalidWithError:
has been issued. When invalidating a background
session, it is not safe to create another
background session with the same identifier
until URLSession:didBecomeInvalidWithError: has been
issued.
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.
Indicates whether the session should set cookies.
This property controls whether tasks within sessions
based on this configuration should automatically
include cookies from the shared cookie store when
making requests. If set to NO, you must
manually provide cookies by adding a Cookie header
through the session's HTTPAdditionalHeaders
property or on a per-request basis using a custom
NSURLRequest object. The default value is
YES. See Also: - HTTPCookieAcceptPolicy
- HTTPCookieStorage - NSHTTPCookieStorage - NSHTTPCookie
Sets whether the session should set cookies. This
method controls whether tasks within sessions based
on this configuration should automatically include
cookies from the shared cookie store when making
requests. If set to NO, you must
manually provide cookies by adding a Cookie header
through the session's HTTPAdditionalHeaders
property or on a per-request basis using a custom
NSURLRequest object. The default value is
YES. See Also: - HTTPCookieAcceptPolicy
- HTTPCookieStorage - NSHTTPCookieStorage - NSHTTPCookie
Gets the timeout interval to use when waiting for
additional data to arrive. The request timeout
interval controls how long (in
seconds) a task should wait for additional data to
arrive before giving up. The timer is reset whenever
new data arrives. When the request timer reaches the
specified interval without receiving any new
data, it triggers a timeout. Currently not used by
NSURLSession.
Gets the maximum amount of time that a resource
request should be allowed to take. The resource
timeout interval controls how long
(in seconds) to wait for an entire resource to transfer
before giving up. The resource timer starts when the
request is initiated and counts until either the
request completes or this timeout interval is
reached, whichever comes first.
Instance Variables for NSURLSessionConfiguration Class
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.
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.
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.
NSURLSession convenience routines deliver
results to a completion handler block. These
convenience routines are not available to
NSURLSessions that are configured as background
sessions. Task objects are always created in a
suspended state and must be sent the
-resume
message before they will execute.