Up
Authors
- Hugo Melder (
hugo@algoriddim.com
)
-
Date: Generated at 2025-07-24 06:37:39 +0000
Copyright: (C) 2017-2024 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSURLSession.h
Availability: MacOS-X 10.9.0
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.
+ (
NSURLSession*)
sessionWithConfiguration: (
NSURLSessionConfiguration*)configuration
delegate: (id<
NSURLSessionDelegate>)delegate
delegateQueue: (
NSOperationQueue*)queue;
Availability: MacOS-X 10.9.0
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.
+ (
NSURLSession*)
sharedSession;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionConfiguration*)
configuration;
Availability: MacOS-X 10.9.0
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.
- (
NSURLSessionDataTask*)
dataTaskWithRequest: (
NSURLRequest*)request;
Availability: MacOS-X 10.9.0
Creates a data task with the given
request. The request may have a
body stream.
- (
NSURLSessionDataTask*)
dataTaskWithURL: (
NSURL*)url;
Availability: MacOS-X 10.9.0
Creates a data task to retrieve the contents of the
given URL.
- (nullable id<
NSURLSessionDelegate>)
delegate;
Availability: MacOS-X 10.9.0
The delegate for the session. This is the object to
which delegate messages will be sent. The session
keeps a strong reference to the delegate.
- (
NSOperationQueue*)
delegateQueue;
Availability: MacOS-X 10.9.0
This serial NSOperationQueue queue is used for
dispatching delegate messages and completion
handlers.
- (void)
finishTasksAndInvalidate;
Availability: MacOS-X 10.9.0
-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.
- (void)
getAllTasksWithCompletionHandler: (void(^)(NSArray<__kindof NSURLSessionTask*>*tasks))completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
getTasksWithCompletionHandler: (void(^)(NSArray
*dataTasks,NSArray*uploadTasks,NSArray*downloadTasks))completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
invalidateAndCancel;
Availability: MacOS-X 10.9.0
- (nullable
NSString*)
sessionDescription;
Availability: MacOS-X 10.9.0
An App-specific description of the session.
- (void)
setSessionDescription: (
NSString*)description;
Availability: MacOS-X 10.9.0
Sets an app-specific description of the
session.
- Declared in:
- Foundation/NSURLSession.h
- Conforms to:
- NSCopying
Availability: MacOS-X 10.9.0
Description forthcoming.
Instance Variables
- (nullable
NSDictionary*)
HTTPAdditionalHeaders;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSHTTPCookieStorage*)
HTTPCookieStorage;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSInteger)
HTTPMaximumConnectionLifetime;
Availability: MacOS-X 10.9.0
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.
- (
NSInteger)
HTTPMaximumConnectionsPerHost;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (BOOL)
HTTPShouldSetCookies;
Availability: MacOS-X 10.9.0
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
- (BOOL)
HTTPShouldUsePipelining;
Availability: MacOS-X 10.9.0
HTTP/1.1 pipelining is not implemented. This flag
is ignored.
- (nullable
NSURLCache*)
URLCache;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSURLCredentialStorage*)
URLCredentialStorage;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSString*)
identifier;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSArray*)
protocolClasses;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setHTTPAdditionalHeaders: (
NSDictionary*)headers;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setHTTPCookieAcceptPolicy: (
NSHTTPCookieAcceptPolicy)policy;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setHTTPCookieStorage: (
NSHTTPCookieStorage*)storage;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setHTTPMaximumConnectionLifetime: (
NSInteger)n;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setHTTPMaximumConnectionsPerHost: (
NSInteger)n;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setHTTPShouldSetCookies: (BOOL)flag;
Availability: MacOS-X 10.9.0
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
- (void)
setHTTPShouldUsePipelining: (BOOL)flag;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setRequestCachePolicy: (
NSURLRequestCachePolicy)policy;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setTimeoutIntervalForRequest: (
NSTimeInterval)interval;
Availability: MacOS-X 10.9.0
Sets the timeout interval to use when
waiting for additional data to arrive.
- (void)
setTimeoutIntervalForResource: (
NSTimeInterval)interval;
Availability: MacOS-X 10.9.0
Sets the maximum amount of time that a resource
request should be allowed to take.
- (void)
setURLCache: (
NSURLCache*)cache;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setURLCredentialStorage: (
NSURLCredentialStorage*)storage;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSTimeInterval)
timeoutIntervalForRequest;
Availability: MacOS-X 10.9.0
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.
- (
NSTimeInterval)
timeoutIntervalForResource;
Availability: MacOS-X 10.9.0
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
@protected NSDictionary*
_HTTPAdditionalHeaders;
Availability: MacOS-X 10.9.0
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.
@protected NSHTTPCookieAcceptPolicy
_HTTPCookieAcceptPolicy;
Availability: MacOS-X 10.9.0
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.
@protected NSHTTPCookieStorage*
_HTTPCookieStorage;
Availability: MacOS-X 10.9.0
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.
@protected NSInteger
_HTTPMaximumConnectionLifetime;
Availability: MacOS-X 10.9.0
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.
@protected NSInteger
_HTTPMaximumConnectionsPerHost;
Availability: MacOS-X 10.9.0
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.
@protected BOOL
_HTTPShouldSetCookies;
Availability: MacOS-X 10.9.0
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.
@protected BOOL
_HTTPShouldUsePipelining;
Availability: MacOS-X 10.9.0
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.
@protected NSURLCache*
_URLCache;
Availability: MacOS-X 10.9.0
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.
@protected NSURLCredentialStorage*
_URLCredentialStorage;
Availability: MacOS-X 10.9.0
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.
@protected NSString*
_identifier;
Availability: MacOS-X 10.9.0
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.
@protected NSArray*
_protocolClasses;
Availability: MacOS-X 10.9.0
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.
@protected NSURLRequestCachePolicy
_requestCachePolicy;
Availability: MacOS-X 10.9.0
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.
@protected NSTimeInterval
_timeoutIntervalForRequest;
Availability: MacOS-X 10.9.0
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.
@protected NSTimeInterval
_timeoutIntervalForResource;
Availability: MacOS-X 10.9.0
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.
- Declared in:
- Foundation/NSURLSession.h
Availability: MacOS-X 10.9.0
Description forthcoming.
Instance Variables
Instance Variables for NSURLSessionDataTask Class
@protected void*
_completionHandler;
Availability: MacOS-X 10.9.0
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.
- Declared in:
- Foundation/NSURLSession.h
Availability: MacOS-X 10.9.0
Description forthcoming.
Instance Variables
Instance Variables for NSURLSessionDownloadTask Class
@protected void*
_completionHandler;
Availability: MacOS-X 10.9.0
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.
@protected int64_t
_countOfBytesWritten;
Availability: MacOS-X 10.9.0
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.
- Declared in:
- Foundation/NSURLSession.h
Availability: MacOS-X 10.11.0
Description forthcoming.
- Declared in:
- Foundation/NSURLSession.h
- Conforms to:
- NSCopying
- NSProgressReporting
Availability: MacOS-X 10.9.0
Description forthcoming.
Instance Variables
- (void)
cancel;
Availability: MacOS-X 10.9.0
Cancels the task and the ongoing transfer.
- (int64_t)
countOfBytesClientExpectsToReceive;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (int64_t)
countOfBytesClientExpectsToSend;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (int64_t)
countOfBytesExpectedToReceive;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (int64_t)
countOfBytesExpectedToSend;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (int64_t)
countOfBytesReceived;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (int64_t)
countOfBytesSent;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSURLRequest*)
currentRequest;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSDate*)
earliestBeginDate;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSError*)
error;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSURLRequest*)
originalRequest;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (float)
priority;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSProgress*)
progress;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSURLResponse*)
response;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
resume;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setDelegate: (nullable id<
NSURLSessionTaskDelegate>)delegate;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setEarliestBeginDate: (nullable
NSDate*)date;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setPriority: (float)priority;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
setTaskDescription: (nullable
NSString*)description;
Availability: MacOS-X 10.9.0
Sets an app-specific description of the
task.
- (void)
suspend;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (nullable
NSString*)
taskDescription;
Availability: MacOS-X 10.9.0
App-specific description of the task.
- (
NSUInteger)
taskIdentifier;
Availability: MacOS-X 10.9.0
Description forthcoming.
Instance Variables for NSURLSessionTask Class
@protected NSURLRequest*
_currentRequest;
Availability: MacOS-X 10.9.0
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.
@protected id
_delegate;
Availability: MacOS-X 10.9.0
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.
@protected NSDate* _earliestBeginDate;
Availability: MacOS-X 10.9.0
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.
@protected NSError* _error;
Availability: MacOS-X 10.9.0
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.
@protected NSURLRequest* _originalRequest;
Availability: MacOS-X 10.9.0
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.
@protected NSProgress* _progress;
Availability: MacOS-X 10.9.0
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.
@protected NSURLResponse* _response;
Availability: MacOS-X 10.9.0
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.
@protected NSURLSessionTaskState _state;
Availability: MacOS-X 10.9.0
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.
@protected NSString* _taskDescription;
Availability: MacOS-X 10.9.0
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.
@protected NSUInteger _taskIdentifier;
Availability: MacOS-X 10.9.0
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.
- Declared in:
- Foundation/NSURLSession.h
Availability: MacOS-X 10.9.0
Description forthcoming.
- Declared in:
- Foundation/NSURLSession.h
Availability: MacOS-X 10.9.0
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.
- (
NSURLSessionDataTask*)
dataTaskWithRequest: (
NSURLRequest*)request
completionHandler: (GSNSURLSessionDataCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionDataTask*)
dataTaskWithURL: (
NSURL*)url
completionHandler: (GSNSURLSessionDataCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionDownloadTask*)
downloadTaskWithRequest: (
NSURLRequest*)request
completionHandler: (GSNSURLSessionDownloadCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionDownloadTask*)
downloadTaskWithResumeData: (
NSData*)resumeData
completionHandler: (GSNSURLSessionDownloadCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionDownloadTask*)
downloadTaskWithURL: (
NSURL*)url
completionHandler: (GSNSURLSessionDownloadCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionUploadTask*)
uploadTaskWithRequest: (
NSURLRequest*)request
fromData: (
NSData*)bodyData
completionHandler: (GSNSURLSessionDataCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (
NSURLSessionUploadTask*)
uploadTaskWithRequest: (
NSURLRequest*)request
fromFile: (
NSURL*)fileURL
completionHandler: (GSNSURLSessionDataCompletionHandler)completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- Declared in:
- Foundation/NSURLSession.h
- Conforms to:
- NSURLSessionTaskDelegate
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
dataTask: (
NSURLSessionDataTask*)dataTask
didReceiveResponse: (
NSURLResponse*)response
completionHandler: (void(^)(NSURLSessionResponseDisposition disposition))completionHandler;
Availability: MacOS-X 10.9.0
Informs the delegate of a response. This
message is sent when all the response
headers have arrived, before the body of the
response arrives.
- Declared in:
- Foundation/NSURLSession.h
- Conforms to:
- NSObject
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
didBecomeInvalidWithError: (nullable
NSError*)error;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
didReceiveChallenge: (
NSURLAuthenticationChallenge*)challenge
completionHandler: (void(^)(NSURLSessionAuthChallengeDisposition disposition,NSURLCredential*credential))handler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- Declared in:
- Foundation/NSURLSession.h
- Conforms to:
- NSURLSessionTaskDelegate
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
downloadTask: (
NSURLSessionDownloadTask*)downloadTask
didResumeAtOffset: (int64_t)fileOffset
expectedTotalBytes: (int64_t)expectedTotalBytes;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
downloadTask: (
NSURLSessionDownloadTask*)downloadTask
didWriteData: (int64_t)bytesWritten
totalBytesWritten: (int64_t)totalBytesWritten
totalBytesExpectedToWrite: (int64_t)totalBytesExpectedToWrite;
Availability: MacOS-X 10.9.0
Description forthcoming.
- Declared in:
- Foundation/NSURLSession.h
- Conforms to:
- NSURLSessionDelegate
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
didCreateTask: (
NSURLSessionTask*)task;
Availability: Not in OpenStep/MacOS-X
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
task: (
NSURLSessionTask*)task
didCompleteWithError: (nullable
NSError*)error;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
task: (
NSURLSessionTask*)task
didReceiveChallenge: (
NSURLAuthenticationChallenge*)challenge
completionHandler: (void(^)(NSURLSessionAuthChallengeDisposition disposition,NSURLCredential*credential))handler;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
task: (
NSURLSessionTask*)task
didSendBodyData: (int64_t)bytesSent
totalBytesSent: (int64_t)totalBytesSent
totalBytesExpectedToSend: (int64_t)totalBytesExpectedToSend;
Availability: MacOS-X 10.9.0
Description forthcoming.
- (void)
URLSession: (
NSURLSession*)session
task: (
NSURLSessionTask*)task
needNewBodyStream: (void(^)(NSInputStream*bodyStream))completionHandler;
Availability: MacOS-X 10.9.0
Description forthcoming.
Up