Contents

appendingPathComponent(_:)

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

Declaration

func appendingPathComponent(_ str: String) -> String

Parameters

  • 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

/tmp

/tmp/scratch.tiff

/tmp/

/tmp/scratch.tiff

/

/scratch.tiff

“” (an empty string)

scratch.tiff

Note that this method only works with file paths (not, for example, string representations of URLs).

See Also

Working with Paths