Platforms to show: All Mac Windows Linux Cross-Platform

NSURLSessionTaskMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Cocoa Networking MBS MacFrameworks Plugin 20.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Function: A task, like downloading a specific resource, performed in a URL session.
The NSURLSessionTaskMBS class is the base class for tasks in a URL session. Tasks are always part of a session; you create a task by calling one of the task creation methods on a NSURLSession instance. The method you call determines the type of task.

  • Use NSURLSessionMBS’s dataTaskWithURL and related methods to create NSURLSessionDataTaskMBS instances. Data tasks request a resource, returning the server’s response as one or more NSData objects in memory. They are supported in default, ephemeral, and shared sessions, but are not supported in background sessions.
  • Use NSURLSessionMBS’s uploadTaskWithRequest and related methods to create NSURLSessionUploadTaskMBS instances. Upload tasks are like data tasks, except that they make it easier to provide a request body so you can upload data before retrieving the server’s response. Additionally, upload tasks are supported in background sessions.
  • Use NSURLSessionMBS’s downloadTaskWithURL and related methods to create NSURLSessionDownloadTaskMBS instances. Download tasks download a resource directly to a file on disk. Download tasks are supported in any type of session.
  • Use NSURLSessionMBS’s streamTaskWithHostName or streamTaskWithNetService to create NSURLSessionStreamTaskMBS instances. Stream tasks establish a TCP/IP connection from a host name and port or a net service object.

After you create a task, you start it by calling its resume method. The session then maintains a strong reference to the task until the request finishes or fails; you don’t need to maintain a reference to the task unless it’s useful for your app’s internal bookkeeping.
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.

Feedback, Comments & Corrections


Constant Value Description
StateCanceling 2 The task has received a cancel message.
The delegate may or may not have received a taskDidCompleteWithError message yet. A task in this state is not subject to timeouts.
StateCompleted 3 The task has completed (without being canceled), and the task's delegate receives no further callbacks.
If the task completed successfully, the task’s error property is nil. Otherwise, it provides an error object that tells what went wrong. A task in this state is not subject to timeouts.
StateRunning 0 The task is currently being serviced by the session.
A task in this state is subject to the request and resource timeouts specified in the session configuration object.
StateSuspended 1 The task was suspended by the app.
No further processing takes place until the task is resumed. A task in this state is not subject to timeouts.

Sub classes:

Some methods using this class:

Some events using this class:

Some examples using this class:

Blog Entries

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

NSURLSessionStreamTaskMBS   -   NSURLSessionTaskMetricsMBS

The biggest plugin in space...

MBS Xojo Plugins

Start Chat