---
title: "init(proxyHost:port:type:realm:authenticationMethod:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/urlprotectionspace/init(proxyhost:port:type:realm:authenticationmethod:)"
---

# init(proxyHost:port:type:realm:authenticationMethod:)

Creates a protection space object representing a proxy server.

## Declaration

```swift
init(proxyHost host: String, port: Int, type: String?, realm: String?, authenticationMethod: String?)
```

## Parameters

- `host`: The host of the proxy server for the protection space object.
- `port`: The port for the protection space object. If port is 0 the default port for the specified proxy type is used, for example, port 80 for HTTP. Note that servers can, and do, treat these values differently.
- `type`: The type of proxy server. The value of proxyType should be set to one of the values specified in doc://com.apple.foundation/documentation/Foundation/nsurlprotectionspace-proxy-types.
- `realm`: A string indicating a protocol specific subdivision of the host. realm may be nil if there is no specified realm or if the protocol doesn’t support realms.
- `authenticationMethod`: The type of authentication to use. authenticationMethod should be set to one of the values in doc://com.apple.foundation/documentation/Foundation/nsurlprotectionspace-authentication-method-constants or nil to use the default, doc://com.apple.foundation/documentation/Foundation/NSURLAuthenticationMethodDefault.

## Return Value

Return Value A new protection space object, with the given host, port, proxyType, realm, and authenticationMethod.

## See Also

### Creating a protection space

- [init(host:port:protocol:realm:authenticationMethod:)](foundation/urlprotectionspace/init(host:port:protocol:realm:authenticationmethod:).md)
