---
title: "appendPathComponent(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/url/appendpathcomponent(_:)"
---

# appendPathComponent(_:)

Appends a path component to the URL.

## Declaration

```swift
mutating func appendPathComponent(_ pathComponent: String)
```

## Parameters

- `pathComponent`: The path component to add.

## Discussion

Discussion note: This function performs a file system operation to determine if the path component is a directory. If so, it will append a trailing /. If you know in advance that the path component is a directory or not, then use func appendingPathComponent(_:isDirectory:). New code should use append(path:directoryHint:) instead of this method.

## See Also

### Adding path components

- [append(path:directoryHint:)](foundation/url/append(path:directoryhint:).md)
- [append(component:directoryHint:)](foundation/url/append(component:directoryhint:).md)
- [appendPathComponent(_:isDirectory:)](foundation/url/appendpathcomponent(_:isdirectory:).md)
- [appending(path:directoryHint:)](foundation/url/appending(path:directoryhint:).md)
- [appending(component:directoryHint:)](foundation/url/appending(component:directoryhint:).md)
- [appendingPathComponent(_:)](foundation/url/appendingpathcomponent(_:).md)
- [appendingPathComponent(_:isDirectory:)](foundation/url/appendingpathcomponent(_:isdirectory:).md)
- [append(components:directoryHint:)](foundation/url/append(components:directoryhint:).md)
- [appending(components:directoryHint:)](foundation/url/appending(components:directoryhint:).md)
- [appendPathComponent(_:conformingTo:)](foundation/url/appendpathcomponent(_:conformingto:).md)
- [appendingPathComponent(_:conformingTo:)](foundation/url/appendingpathcomponent(_:conformingto:).md)
