Platforms to show: All Mac Windows Linux Cross-Platform
NSURLSessionDownloadTaskMBS class
Super class: NSURLSessionTaskMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Cocoa Networking | MBS MacFrameworks Plugin | 20.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
An NSURLSessionDownloadTaskMBS is a concrete subclass of NSURLSessionTask. Most of the methods associated with this class are documented in NSURLSessionTaskMBS.
Download tasks directly write the server’s response data to a temporary file, providing your app with progress updates as data arrives from the server. When you use download tasks in background sessions, these downloads continue even when your app is suspended or is otherwise not running.
You can pause (cancel) download tasks and resume them later (assuming the server supports doing so). You can also resume downloads that failed because of network connectivity problems.
When you use a download task, your NSURLSessionMBS subclass receives several callbacks unique to download scenarios.
- During download, the session periodically calls the downloadTaskDidWriteData event with status information.
- Upon successful completion, the session calls the downloadTaskDidFinishDownloadingToURL event or completion handler. In that method, you must either open the file for reading or move it to a permanent location in your app’s sandbox container directory.
- Upon unsuccessful completion, the session calls the taskDidCompleteWithError method or completion handler. Unlike NSURLSessionDataTaskMBS or NSURLSessionUploadTaskMBS, a download task reports server-side errors reported through HTTP status codes into corresponding NSError objects.
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.
- 2 methods
- method cancelByProducingResumeData(Handler as ProducingResumeDataCompletedMBS, tag as variant = nil)
- method Constructor Private
- shared method NSURLSessionDownloadTaskResumeData as string
- delegate ProducingResumeDataCompletedMBS(downloadTask as NSURLSessionDownloadTaskMBS, resumeData as MemoryBlock, tag as variant)
Super class NSURLSessionTaskMBS
- 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. |
This class has no sub classes.
Some methods using this class:
- NSURLSessionMBS.downloadTaskWithRequest(request as NSURLRequestMBS) as NSURLSessionDownloadTaskMBS
- NSURLSessionMBS.downloadTaskWithResumeData(resumeData as MemoryBlock) as NSURLSessionDownloadTaskMBS
- NSURLSessionMBS.downloadTaskWithURL(URL as String) as NSURLSessionDownloadTaskMBS
Some events using this class:
- NSURLSessionMBS.dataTaskDidBecomeDownloadTask(dataTask as NSURLSessionDataTaskMBS, downloadTask as NSURLSessionDownloadTaskMBS)
- NSURLSessionMBS.downloadTaskDidFinishDownloadingToURL(downloadTask as NSURLSessionDownloadTaskMBS, location as String, file as FolderItem)
- NSURLSessionMBS.downloadTaskDidResumeAtOffset(downloadTask as NSURLSessionDownloadTaskMBS, fileOffset as Int64, expectedTotalBytes as Int64)
- NSURLSessionMBS.downloadTaskDidWriteData(downloadTask as NSURLSessionDownloadTaskMBS, bytesWritten as Int64, totalBytesWritten as Int64, totalBytesExpectedToWrite as Int64)
Some examples using this class:
Blog Entries
The items on this page are in the following plugins: MBS MacFrameworks Plugin.
NSURLSessionDataTaskMBS - NSURLSessionMBS