The NSURLResponse class encapsulates the metadata associated with the response to a a URL load request in a manner independent of protocol and URL scheme.


The related HTTPURLResponse class is a commonly used subclass of NSURLResponse whose objects represent a response to an HTTP URL load request and store additional protocol-specific information such as the response headers. Whenever you make an HTTP request, the NSURLResponse object you get back is actually an instance of the HTTPURLResponse class.


Creating a response

init(url: URL, mimeType: String?, expectedContentLength: Int, textEncodingName: String?)

Returns an initialized NSURLResponse object with the URL, MIME type, length, and text encoding set to given values.

Getting the response properties

var expectedContentLength: Int64

The expected length of the response’s content.

var suggestedFilename: String?

A suggested filename for the response data.

var mimeType: String?

The MIME type of the response.

var textEncodingName: String?

The name of the text encoding provided by the response’s originating source.

var url: URL?

The URL for the response.


Inherits From