init(host:port:protocol:realm:authenticationMethod:)
Creates a protection space object from the given host, port, protocol, realm, and authentication method.
Declaration
init(host: String, port: Int, protocol: String?, realm: String?, authenticationMethod: String?)Parameters
- host:
The host name for the Urlprotectionspace object.
- port:
The port for the protection space object. If
portis 0, the default port for the specified protocol is used, for example, port 80 for HTTP. Note that servers can, and do, treat these values differently. - protocol:
The protocol for the protection space object. The value of
protocolis equivalent to the scheme for a URL in the protection space, for example, “http”, “https”, “ftp”, etc. - realm:
A string indicating a protocol-specific subdivision of the host.
realmmay benilif there is no specified realm or if the protocol doesn’t support realms. - authenticationMethod:
The type of authentication to use.
authenticationMethodshould be set to one of the values in Nsurlprotectionspace Authentication Method Constants ornilto use the default, Nsurlauthenticationmethoddefault.
Return Value
A new protection space object, initialized with the given host, port, protocol, realm, and authentication method.