Instance Method


Returns a new string made by appending to the receiver a given string.


func appendingPathComponent(_ str: String) -> String



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.


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

Related Symbols

func strings(byAppendingPaths: [String])

Returns an array of strings made by separately appending to the receiver each string in in a given array.

func appendingPathExtension(String)

Returns a new string made by appending to the receiver an extension separator followed by a given extension.

var deletingLastPathComponent: String

A new string made by deleting the last path component from the receiver, along with any final path separator.