---
title: host
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsurlcomponents/host
---

# host

The host URL subcomponent, or nil if not present.

## Declaration

```swift
var host: String? { get set }
```

## Discussion

Discussion For example, in the URL http://www.example.com/index.html, the host is www.example.com. The getter for this property removes any percent encoding this component may have (if the component allows percent encoding). Setting this property assumes the subcomponent or component string isn’t percent encoded and adds percent encoding (if the component allows percent encoding).

## See Also

### Accessing components in native format

- [fragment](foundation/nsurlcomponents/fragment.md)
- [encodedHost](foundation/nsurlcomponents/encodedhost.md)
- [password](foundation/nsurlcomponents/password.md)
- [path](foundation/nsurlcomponents/path.md)
- [port](foundation/nsurlcomponents/port.md)
- [query](foundation/nsurlcomponents/query.md)
- [queryItems](foundation/nsurlcomponents/queryitems.md)
- [scheme](foundation/nsurlcomponents/scheme.md)
- [user](foundation/nsurlcomponents/user.md)
