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

# appendingPathComponent(_:conformingTo:)

Returns a URL by appending the specified path component that conforms to a uniform type identifier.

## Declaration

```swift
func appendingPathComponent(_ partialName: String, conformingTo contentType: UTType) -> URL
```

## Parameters

- `partialName`: The name of path component without the type.
- `contentType`: A uniform type identifier that determines the default extension.

## Return Value

Return Value A new URL with the partial name and the type’s preferred extension appended.

## Discussion

Discussion Use this method when you want to mix partial input from a user or other source, and need to produce a complete filename suitable for that input. For example, if you download a file from the internet and know its MIME type, you can use this method to ensure the URL has the correct filename extension where you save the file. If partialName already has a path extension, and that path extension is valid for file system objects of type contentType, the function doesn’t add an extension before appending it to the URL. For example, if the inputs are puppy.jpg and jpeg, respectively, the function returns a URL with an appended path component of puppy.jpg. However, if the inputs are puppy.jpg and plainText, respectively, the function returns a URL with an appended path component of puppy.jpg.txt. If you want to replace any existing path extension, use the deletePathExtension() method first. If the function can’t append the path component, it returns an unchanged URL. note: The modified URL has a directory path if contentType conforms to directory. For more information about types, see Uniform Type Identifiers.

## See Also

### Adding path components

- [append(path:directoryHint:)](foundation/url/append(path:directoryhint:).md)
- [append(component:directoryHint:)](foundation/url/append(component:directoryhint:).md)
- [appendPathComponent(_:)](foundation/url/appendpathcomponent(_:).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)
