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

# string

A URL derived from the components object, in string form.

## Declaration

```swift
var string: String? { get }
```

## Discussion

Discussion If the receiver has an authority component (user, password, host, or port) and a path component, then the path must either begin with "/" or be an empty string. Otherwise, this property contains nil. If the receiver  does not have an authority component (user, password, host, or port) and has a path component, the path component must not start with "//". If it does, this property contains nil. This property can be used only to obtain a URL string based on the values of the other properties. To configure a components object based on an existing URL string, call either the componentsWithString: or init(string:) method.

## See Also

### Getting the URL

- [url](foundation/nsurlcomponents/url.md)
- [url(relativeTo:)](foundation/nsurlcomponents/url(relativeto:).md)
