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 |
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.
- 17 properties
- property countOfBytesClientExpectsToReceive as Int64
- property countOfBytesClientExpectsToSend as Int64
- property countOfBytesExpectedToReceive as Int64
- property countOfBytesExpectedToSend as Int64
- property countOfBytesReceived as Int64
- property countOfBytesSent as Int64
- property currentRequest as NSURLRequestMBS
- property earliestBeginDate as Date
- property earliestBeginDateTime as DateTime
- property error as NSErrorMBS
- property Handle as Integer
- property originalRequest as NSURLRequestMBS
- property Priority as Single
- property response as NSURLResponseMBS
- property state as Integer
- property taskDescription as String
- property taskIdentifier as UInt64
- 5 methods
- method Cancel
- method Constructor Private
- method copy as NSURLSessionTaskMBS
- method resume
- method suspend
- 4 shared methods
- shared method available as Boolean
- shared method PriorityDefault as Single
- shared method PriorityHigh as Single
- shared method PriorityLow as Single
- 4 constants
States
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. more |
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:
- class NSURLSessionDataTaskMBS
- class NSURLSessionDownloadTaskMBS
- class NSURLSessionStreamTaskMBS
- class NSURLSessionWebSocketTaskMBS
Some methods using this class:
- NSURLSessionMBS.Tasks as NSURLSessionTaskMBS()
Some events using this class:
- NSURLSessionMBS.taskDidCompleteWithError(task as NSURLSessionTaskMBS, error as NSErrorMBS)
- NSURLSessionMBS.taskDidFinishCollectingMetrics(task as NSURLSessionTaskMBS, metrics as NSURLSessionTaskMetricsMBS)
- NSURLSessionMBS.taskDidSendBodyData(task as NSURLSessionTaskMBS, bytesSent as Int64, totalBytesSent as Int64, totalBytesExpectedToSend as Integer)
- NSURLSessionMBS.taskIsWaitingForConnectivity(task as NSURLSessionTaskMBS)
- NSURLSessionMBS.taskWillPerformHTTPRedirection(task as NSURLSessionTaskMBS, response as NSURLResponseMBS, request as NSURLRequestMBS) as NSURLRequestMBS
Some examples using this class:
Blog Entries
Release notes
- Version 22.2
- Changed NSURLSessionTaskMBS.taskDescription property to be settable.
The items on this page are in the following plugins: MBS MacFrameworks Plugin.
NSURLSessionStreamTaskMBS - NSURLSessionTaskMetricsMBS