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

# percentEncodedQuery

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

## Declaration

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

## Discussion

Discussion For example, in the URL http://www.example.com/index.php?key1=value1&key2=value2, the query string is key1=value1&key2=value2. If you set this value to something that is not a valid, percent-encoded string, this class throws an exception.

## See Also

### Accessing components in URL-encoded format

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