Adding NSURLSession classes for Xojo
When using the classes, please first create an object of NSURLSessionConfigurationMBS class. Configure it to the options you need, e.g. what caching or cookie policies you like or whether to allow cellular or expensive connections.
Next you can initialize a new NSURLSessionMBS, usually via constructor and your own subclass to fill in the events. Alternatively for simple transfers you can use the sharedSession and use the default settings.
Then you use one of the NSURLSessionTaskMBS subclasses:
- NSURLSessionDataTaskMBS to run a normal HTTP request with result in memory.
- NSURLSessionUploadTaskMBS to do a HTTP upload with POST or PUT.
- NSURLSessionDownloadTaskMBS to download a bigger file to disk. This includes support for pausing and resuming downloads.
- NSURLSessionStreamTaskMBS allows you to skip the HTTP protocol and do your own streaming of whatever data you have.
- NSURLSessionWebSocketTaskMBS new in MacOS 10.15 allows to connect via web socket connection and allow you to send messages.
We formally deprecate NSURLConnectionMBS class, which is the older set of classes Apple provides for HTTP connections. You should move to NSURLSessionMBS soon. We won't remove them until Apple removes them, but you never know whether they will be part of next OS version.