Instance Method

appendingPathComponent(_:)

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

Declaration

func appendingPathComponent(_ str: String) -> String

Parameters

aString

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

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.