A new string made by removing extraneous path components from the receiver.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
A new string made by performing the following operations:
Expanding an initial tilde expression using
By Expanding Tilde In Path
Removing an initial component of “
/var/automount”, or “
/private” from the path, if the result still indicates an existing file or directory (checked by consulting the file system).
Reducing empty components and references to the current directory (that is, the sequences “//” and “/./”) to single path separators.
Removing a trailing slash from the last component.
For absolute paths only, resolving references to the parent directory (that is, the component “..”) to the real parent directory if possible using
string. For relative paths, references to the parent directory are left in place.
By Resolving Symlinks In Path
self if an error occurs.
Note that the path returned by this method may still have symbolic link components in it. Note also that this method only works with file paths (not, for example, string representations of URLs).