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

# scheme

The scheme URL component, or nil if not present.

## Declaration

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

## Discussion

Discussion For example, in the URL http://www.example.com/index.html, the scheme is http. If you attempt to set the scheme to an invalid scheme string, this class throws an exception. note: The term “protocol” is also sometimes used when talking about network-based URL schemes. However, not all URL schemes are networking protocols—data:// URLs, for example.

## See Also

### Accessing components in native format

- [fragment](foundation/nsurlcomponents/fragment.md)
- [host](foundation/nsurlcomponents/host.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)
- [user](foundation/nsurlcomponents/user.md)
