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

# percentEncodedPath

The path URL component expressed as a URL-encoded string, or nil if not present.

## Declaration

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

## Discussion

Discussion For example, in the URL http://www.example.com/index.html, the path is /index.html. If you set this value to something that is not a valid, percent-encoded string, this class throws an exception. note: Although an unencoded semicolon is a valid character in a percent-encoded path, for compatibility with the NSURL class, you should always percent-encode it. To properly encode a string for use in the path component of a URL, use the character set returned by the URLPathAllowedCharacterSet method in conjunction with the addingPercentEncoding(withAllowedCharacters:) method.

## See Also

### Accessing components in URL-encoded format

- [percentEncodedFragment](foundation/nsurlcomponents/percentencodedfragment.md)
- [percentEncodedHost](foundation/nsurlcomponents/percentencodedhost.md)
- [percentEncodedPassword](foundation/nsurlcomponents/percentencodedpassword.md)
- [percentEncodedQuery](foundation/nsurlcomponents/percentencodedquery.md)
- [percentEncodedUser](foundation/nsurlcomponents/percentencodeduser.md)
