---
title: "appendingPathComponent(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurl/appendingpathcomponent(_:)"
---

# appendingPathComponent(_:)

Returns a new URL by appending a path component to the original URL.

## Declaration

```swift
func appendingPathComponent(_ pathComponent: String) -> URL?
```

## Parameters

- `pathComponent`: The path component to add to the URL, in its original form (not URL encoded).

## Mentioned in

Improving performance and stability when accessing the file system

## Return Value

Return Value A new URL with pathComponent appended.

## Discussion

Discussion If the original URL does not end with a forward slash and pathComponent does not begin with a forward slash, a forward slash is inserted between the two parts of the returned URL, unless the original URL is the empty string. If the receiver is a file URL and pathComponent does not end with a trailing slash, this method may read file metadata to determine whether the resulting path is a directory. This is done synchronously, and may have significant performance costs if the receiver is a location on a network mounted filesystem. You can instead call the appendingPathComponent(_:isDirectory:) method if you know whether the resulting path is a directory to avoid this file metadata operation.

## See Also

### Modifying and Converting a File URL

- [filePathURL](foundation/nsurl/filepathurl.md)
- [fileReferenceURL()](foundation/nsurl/filereferenceurl().md)
- [appendingPathComponent(_:isDirectory:)](foundation/nsurl/appendingpathcomponent(_:isdirectory:).md)
- [appendingPathComponent(_:conformingTo:)](foundation/nsurl/appendingpathcomponent(_:conformingto:).md)
- [appendingPathExtension(_:)](foundation/nsurl/appendingpathextension(_:).md)
- [appendingPathExtension(for:)](foundation/nsurl/appendingpathextension(for:).md)
- [deletingLastPathComponent](foundation/nsurl/deletinglastpathcomponent.md)
- [deletingPathExtension](foundation/nsurl/deletingpathextension.md)
- [resolvingSymlinksInPath](foundation/nsurl/resolvingsymlinksinpath.md)
- [standardizingPath](foundation/nsurl/standardizingpath.md)
- [hasDirectoryPath](foundation/nsurl/hasdirectorypath.md)
