Instance Property

deletingLastPathComponent

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

Declaration

var deletingLastPathComponent: String { get }

Discussion

A new string made by deleting the last path component from the receiver, along with any final path separator. If the receiver represents the root path it is returned unaltered.

The following table illustrates the effect of this method on a variety of different paths:

Receiver’s String Value

Resulting String

/tmp/scratch.tiff

/tmp

/tmp/lock/

/tmp

/tmp/

/

/tmp

/

/

/

scratch.tiff

“” (an empty string)

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

See Also

Related Symbols

func appendingPathComponent(String)

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

var deletingPathExtension: String

A new string made by deleting the extension (if any, and only the last) from the receiver.