appendingPathComponent(_:)
Returns a new string made by appending to the receiver a given string.
Declaration
func appendingPathComponent(_ str: String) -> StringParameters
- str:
The path component to append to the receiver.
Return Value
A new string made by appending aString to the receiver, preceded if necessary by a path separator.
Discussion
The following table illustrates the effect of this method on a variety of different paths, assuming that aString is supplied as “scratch.tiff”:
Receiver’s String Value | Resulting String |
|---|---|
“ | “ |
“ | “ |
“ | “ |
“” (an empty string) | “ |
Note that this method only works with file paths (not, for example, string representations of URLs).
See Also
Working with Paths
path(withComponents:)pathComponentscompletePath(into:caseSensitive:matchesInto:filterTypes:)fileSystemRepresentationgetFileSystemRepresentation(_:maxLength:)isAbsolutePathlastPathComponentpathExtensionabbreviatingWithTildeInPathappendingPathExtension(_:)deletingLastPathComponentdeletingPathExtensionexpandingTildeInPathresolvingSymlinksInPathstandardizingPath