---
title: "path(withComponents:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsstring/path(withcomponents:)"
---

# path(withComponents:)

Returns a string built from the strings in a given array by concatenating them with a path separator between each pair.

## Declaration

```swift
class func path(withComponents components: [String]) -> String
```

## Parameters

- `components`: An array of NSString objects representing a file path. To create an absolute path, use a slash mark (”/”) as the first component. To include a trailing path divider, use an empty string as the last component.

## Return Value

Return Value A string built from the strings in components by concatenating them (in the order they appear in the array) with a path separator between each pair.

## Discussion

Discussion This method doesn’t clean up the path created; use standardizingPath to resolve empty components, references to the parent directory, and so on.

## See Also

### Working with Paths

- [pathComponents](foundation/nsstring/pathcomponents.md)
- [completePath(into:caseSensitive:matchesInto:filterTypes:)](foundation/nsstring/completepath(into:casesensitive:matchesinto:filtertypes:).md)
- [fileSystemRepresentation](foundation/nsstring/filesystemrepresentation.md)
- [getFileSystemRepresentation(_:maxLength:)](foundation/nsstring/getfilesystemrepresentation(_:maxlength:).md)
- [isAbsolutePath](foundation/nsstring/isabsolutepath.md)
- [lastPathComponent](foundation/nsstring/lastpathcomponent.md)
- [pathExtension](foundation/nsstring/pathextension.md)
- [abbreviatingWithTildeInPath](foundation/nsstring/abbreviatingwithtildeinpath.md)
- [appendingPathComponent(_:)](foundation/nsstring/appendingpathcomponent(_:).md)
- [appendingPathExtension(_:)](foundation/nsstring/appendingpathextension(_:).md)
- [deletingLastPathComponent](foundation/nsstring/deletinglastpathcomponent.md)
- [deletingPathExtension](foundation/nsstring/deletingpathextension.md)
- [expandingTildeInPath](foundation/nsstring/expandingtildeinpath.md)
- [resolvingSymlinksInPath](foundation/nsstring/resolvingsymlinksinpath.md)
- [standardizingPath](foundation/nsstring/standardizingpath.md)
