Platforms to show: All Mac Windows Linux Cross-Platform

NSURLSessionMBS.Constructor
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates new object referencing shared session.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.Constructor(configuration as NSURLSessionConfigurationMBS)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a session with the specified session configuration.
Notes:
configuration: A configuration object that specifies certain behaviors, such as caching policies, timeouts, proxies, pipelining, TLS versions to support, cookie policies, credential storage, and so on.
See NSURLSessionConfigurationMBS class for more information.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.dataTaskWithRequest(request as NSURLRequestMBS) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that retrieves the contents of a URL based on the specified URL request object.
Notes:
request: A URL request object that provides request-specific information such as the URL, cache policy, request type, and body data or body stream.

Returns he new session data task.

By creating a task based on a request object, you can tune various aspects of the task’s behavior, including the cache policy and timeout interval.
After you create the task, you must start it by calling its resume method.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.dataTaskWithRequest(request as NSURLRequestMBS, handler as NSURLSessionDataTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that retrieves the contents of a URL based on the specified URL request object, and calls a handler upon completion.
Notes:
request: A URL request object that provides the URL, cache policy, request type, body data or body stream, and so on.
completionHandler: The completion handler to call when the load request is complete.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.dataTaskWithURL(URL as String) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that retrieves the contents of the specified URL.
Notes:
URL: The URL to be retrieved.

After you create the task, you must start it by calling its resume method. The task calls methods on the session’s delegate to provide you with the response metadata, response data, and so on.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.dataTaskWithURL(URL as String, handler as NSURLSessionDataTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that retrieves the contents of the specified URL, then calls a handler upon completion.
Notes:
url: The URL to be retrieved.
handler: The completion handler to call when the load request is complete.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.downloadTaskWithRequest(request as NSURLRequestMBS) as NSURLSessionDownloadTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a download task that retrieves the contents of a URL based on the specified URL request object and saves the results to a file.
Notes:
request: A URL request object that provides the URL, cache policy, request type, body data or body stream, and so on.

Returns the new session download task.

By creating a task based on a request object, you can tune various aspects of the task’s behavior, including the cache policy and timeout interval.
After you create the task, you must start it by calling its resume method. The task calls methods on the session’s delegate to provide you with progress notifications, the location of the resulting temporary file, and so on.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.downloadTaskWithRequest(request as NSURLRequestMBS, handler as NSURLSessionUploadTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a download task that retrieves the contents of a URL based on the specified URL request object, saves the results to a file, and calls a handler upon completion.
Notes:
request: A URL request object that provides the URL, cache policy, request type, body data or body stream, and so on.
Handler: The completion handler to call when the load request is complete.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.downloadTaskWithResumeData(resumeData as MemoryBlock) as NSURLSessionDownloadTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a download task to resume a previously canceled or failed download.
Notes:
resumeData: A data object that provides the data necessary to resume a download.

After you create the task, you must start it by calling its resume method.
This method is equivalent to the downloadTaskWithResumeData:completionHandler: with a nil completion handler. For detailed usage information, including ways to obtain a resume data object, see that method.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.downloadTaskWithResumeData(resumeData as MemoryBlock, handler as NSURLSessionUploadTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a download task to resume a previously canceled or failed download and calls a handler upon completion.
Notes:
resumeData: A data object that provides the data necessary to resume the download.
Handler: The completion handler to call when the load request is complete.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.downloadTaskWithURL(URL as String) as NSURLSessionDownloadTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a download task that retrieves the contents of the specified URL and saves the results to a file.
Notes:
url: The URL to download.

After you create the task, you must start it by calling its resume method.

See also:

Some examples using this method:

Feedback, Comments & Corrections

NSURLSessionMBS.downloadTaskWithURL(URL as String, handler as NSURLSessionUploadTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a download task that retrieves the contents of the specified URL, saves the results to a file, and calls a handler upon completion.
Notes:
url: An URL that provides the URL to download.
Handler: The completion handler to call when the load request is complete.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.finishTasksAndInvalidate
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Invalidates the session, allowing any outstanding tasks to finish.
Notes:
This method returns immediately without waiting for tasks to finish. Once a session is invalidated, new tasks cannot be created in the session, but existing tasks continue until completion. After the last task finishes and the session makes the last delegate call related to those tasks, the session calls the DidBecomeInvalidWithError event, then breaks references to the delegate and callback objects. After invalidation, session objects cannot be reused.
To cancel all outstanding tasks, call invalidateAndCancel instead.

Important
Calling this method on the session returned by the sharedSession method has no effect.

Feedback, Comments & Corrections

NSURLSessionMBS.flush(Handler as NSURLSessionFlushCompletedMBS = nil, tag as variant = nil)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Flushes cookies and credentials to disk, clears transient caches, and ensures that future requests occur on a new TCP connection.
Notes: Handler: The completion handler to call when the flush operation is complete.

Feedback, Comments & Corrections

NSURLSessionMBS.invalidateAndCancel
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Cancels all outstanding tasks and then invalidates the session.
Notes:
Once invalidated, references to the delegate and callback objects are broken. After invalidation, session objects cannot be reused.
To allow outstanding tasks to run until completion, call finishTasksAndInvalidate instead.

Important
Calling this method on the session returned by the sharedSession method has no effect.

Some examples using this method:

Feedback, Comments & Corrections

NSURLSessionMBS.reset(Handler as NSURLSessionResetCompletedMBS = nil, tag as variant = nil)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Resets the session.
Notes:
Empties all cookies, caches and credential stores, removes disk files, flushes in-progress downloads to disk, and ensures that future requests occur on a new socket.

Handler: The completion handler to call when the reset operation is complete.

Feedback, Comments & Corrections

NSURLSessionMBS.streamTaskWithHostName(hostname as String, Port as Integer) as NSURLSessionStreamTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that establishes a bidirectional TCP/IP connection to a specified hostname and port.
Notes:
hostname: The hostname of the connection endpoint.
port: The port of the connection endpoint.

Returns the new session stream task.

After you create the task, you must start it by calling its resume method.

Some examples using this method:

Feedback, Comments & Corrections

NSURLSessionMBS.Tasks as NSURLSessionTaskMBS()
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Queries all tasks for the session.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.Tasks(Handler as NSURLSessionTasksCompletedMBS, tag as variant = nil)
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Asynchronously calls a completion callback with all data, upload, and download tasks in a session.
Notes:
Handler: The completion handler to call with the list of tasks. This handler is executed on the delegate queue.

The arrays passed to the completion handler contain any tasks that you have created within the session, not including any tasks that have been invalidated after completing, failing, or being cancelled.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.uploadTaskWithRequest(request as NSURLRequestMBS, data as MemoryBlock) as NSURLSessionUploadTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that performs an HTTP request for the specified URL request object and uploads the provided data.
Notes:
request: A URL request object that provides the URL, cache policy, request type, and so on. The body stream and body data in this request object are ignored.
Data: The body data for the request.

Returns the new session upload task.

An HTTP upload request is any request that contains a request body, such as a POST or PUT request. Upload tasks require you to create a request object so that you can provide metadata for the upload, like HTTP request headers.
After you create the task, you must start it by calling its resume method. The task calls methods on the session’s delegate to provide you with the upload’s progress, response metadata, response data, and so on.

See also:

Some examples using this method:

Feedback, Comments & Corrections

NSURLSessionMBS.uploadTaskWithRequest(request as NSURLRequestMBS, data as MemoryBlock, handler as NSURLSessionUploadTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that performs an HTTP request for the specified URL request object, uploads the provided data, and calls a handler upon completion.
Notes:
request: A URL request object that provides the URL, cache policy, request type, and so on. The body stream and body data in this request object are ignored.
bodyData: The body data for the request.
Handler: The completion handler to call when the load request is complete.

Returns the new session upload task.

An HTTP upload request is any request that contains a request body, such as a POST or PUT request. Upload tasks require you to create a request object so that you can provide metadata for the upload, like HTTP request headers.

Unlike uploadTaskWithRequest, this method returns the response body after it has been received in full, and does not require you to write a custom delegate to obtain the response body.

By using a completion handler, the task bypasses calls to delegate methods for response and data delivery, and instead provides any resulting data, response, or error inside the completion handler. Delegate methods for handling authentication challenges, however, are still called.

Typically you pass a nil completion handler only when creating tasks in sessions whose delegates include a dataTaskDidReceiveData method. However, if you do not need the response data, use key-value observing to watch for changes to the task’s status to determine when it completes.

After you create the task, you must start it by calling its resume method.

If the request completes successfully, the data parameter of the completion handler block contains the resource data, and the error parameter is nil. If the request fails, the data parameter is nil, and the error parameter contains information about the failure. If a response from the server is received, regardless of whether the request completes successfully or fails, the response parameter contains that information.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.uploadTaskWithRequest(request as NSURLRequestMBS, file as folderItem) as NSURLSessionUploadTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that performs an HTTP request for uploading the specified file.
Notes:
request: A URL request object that provides the URL, cache policy, request type, and so on. The body stream and body data in this request object are ignored.
file: The file to upload.

Returns the new session upload task.

An HTTP upload request is any request that contains a request body, such as a POST or PUT request. Upload tasks require you to create a request object so that you can provide metadata for the upload, like HTTP request headers.
After you create the task, you must start it by calling its resume method. The task calls methods on the session’s delegate to provide you with the upload’s progress, response metadata, response data, and so on.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.uploadTaskWithRequest(request as NSURLRequestMBS, file as FolderItem, handler as NSURLSessionUploadTaskCompletedMBS, tag as Variant = nil) as NSURLSessionDataTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that performs an HTTP request for uploading the specified file, then calls a handler upon completion.
Notes:
request: An NSURLRequestMBS instance that provides the URL, cache policy, request type, and so on. The body stream and body data in this request object are ignored.
file: The file to upload.
Handler: The completion handler to call when the load request is complete.

An HTTP upload request is any request that contains a request body, such as a POST or PUT request. Upload tasks require you to create a request object so that you can provide metadata for the upload, like HTTP request headers.

Unlike uploadTaskWithRequest, this method returns the response body after it has been received in full, and does not require you to write a custom delegate to obtain the response body.

By using a completion handler, the task bypasses calls to delegate methods for response and data delivery, and instead provides any resulting data, response, or error inside the completion handler. Delegate methods for handling authentication challenges, however, are still called.

Typically you usually pass a nil completion handler only when creating tasks in sessions whose delegates include a dataTaskDidReceiveData method. However, if you do not need the response data, use key-value observing to watch for changes to the task’s status to determine when it completes.

After you create the task, you must start it by calling its resume method.

If the request completes successfully, the data parameter of the completion handler block contains the resource data, and the error parameter is nil. If the request fails, the data parameter is nil, and the error parameter contains information about the failure. If a response from the server is received, regardless of whether the request completes successfully or fails, the response parameter contains that information.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.uploadTaskWithStreamedRequest(request as NSURLRequestMBS) as NSURLSessionUploadTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a task that performs an HTTP request for uploading data based on the specified URL request.
Notes:
request: A URL request object that provides the URL, cache policy, request type, and so on. The body stream and body data in this request object are ignored, and the session calls its taskNeedNewBodyStream event to provide the body data.

Returns the new session upload task.

An HTTP upload request is any request that contains a request body, such as a POST or PUT request. Upload tasks require you to provide a request object so that you can provide metadata for the upload, such as HTTP request headers.
After you create the task, you must start it by calling its resume method. The task calls methods on the session’s delegate to provide you with the upload’s progress, response metadata, response data, and so on. The session must have a taskNeedNewBodyStream event that provides the body data to upload.

Feedback, Comments & Corrections

NSURLSessionMBS.webSocketTaskWithRequest(request as NSURLRequestMBS) as NSURLSessionWebSocketTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a WebSocket task for the provided URL request.
Notes:
request: A URL request that indicates a WebSockets endpoint with which to connect.

You can modify the request’s properties prior to calling resume on the task. The task uses these properties during the HTTP handshake phase.
To add custom protocols, add a header with the key Sec-WebSocket-Protocol, and a comma-separated list of protocols you want to negotiate with the server. The custom HTTP headers provided by the client remain unchanged for the handshake with the server.

Feedback, Comments & Corrections

NSURLSessionMBS.webSocketTaskWithURL(URL as String) as NSURLSessionWebSocketTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a WebSocket task for the provided URL.
Notes:
url: The WebSocket URL with which to connect.

The provided URL must have a ws or wss scheme.

See also:

Feedback, Comments & Corrections

NSURLSessionMBS.webSocketTaskWithURL(URL as String, Protocols() as String) as NSURLSessionWebSocketTaskMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: Creates a WebSocket task given a URL and an array of protocols.
Notes:
url: The WebSocket URL with which to connect.
protocols: An array of protocols to negotiate with the server.

During the WebSocket handshake, the task uses the provided protocols to negotiate a preferred protocol with the server.

The protocol doesn’t affect the WebSocket framing. More details on the protocol are available in RFC 6455, The WebSocket Protocol.

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacFrameworks Plugin.

The biggest plugin in space...




Links
MBS Xojo blog

Start Chat