pathExtension
The path extension, if any, of the string as interpreted as a path.
Declaration
var pathExtension: String { get }Discussion
The path extension is the portion of the last path component which follows the final period, if there is one. The extension divider is not included. The following table illustrates the effect of pathExtension on a variety of different paths:
Receiver’s String Value | String Returned |
|---|---|
“ | “ |
“ | “ |
“ | “” (an empty 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:)isAbsolutePathlastPathComponentabbreviatingWithTildeInPathappendingPathComponent(_:)appendingPathExtension(_:)deletingLastPathComponentdeletingPathExtensionexpandingTildeInPathresolvingSymlinksInPathstandardizingPath