---
title: lastPathComponent
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/url/lastpathcomponent
---

# lastPathComponent

The last path component of the URL, or an empty string if the path is an empty string.

## Declaration

```swift
var lastPathComponent: String { get }
```

## See Also

### Accessing the parts of a URL

- [fragment(percentEncoded:)](foundation/url/fragment(percentencoded:).md)
- [fragment](foundation/url/fragment.md)
- [host(percentEncoded:)](foundation/url/host(percentencoded:).md)
- [host](foundation/url/host.md)
- [path(percentEncoded:)](foundation/url/path(percentencoded:).md)
- [path](foundation/url/path.md)
- [password(percentEncoded:)](foundation/url/password(percentencoded:).md)
- [password](foundation/url/password.md)
- [pathComponents](foundation/url/pathcomponents.md)
- [pathExtension](foundation/url/pathextension.md)
- [port](foundation/url/port.md)
- [query(percentEncoded:)](foundation/url/query(percentencoded:).md)
- [query](foundation/url/query.md)
- [scheme](foundation/url/scheme.md)
- [user(percentEncoded:)](foundation/url/user(percentencoded:).md)
