Generic Instance Method


Passes the URL’s path in the file system representation to a closure.


func withUnsafeFileSystemRepresentation<ResultType>(_ block: (UnsafePointer<Int8>?) throws -> ResultType) rethrows -> ResultType



A closure to execute, which receives a C string as its parameter, and returns a value of a type you choose.

The parameter passed to the closure is nil if the URL cannot be represented by the file system. For example, if the URL contains an accented character and the file system only supports ASCII, no file system representation is possible.

Return Value

The value returned by your closure, if any.


The file system representation is a null-terminated C string with canonical UTF-8 encoding.

See Also

Working with File URLs

var isFileURL: Bool

A Boolean that is true if the scheme is file:.

var hasDirectoryPath: Bool

A Boolean that is true if the URL path represents a directory.

func resolveSymlinksInPath()

Resolves any symlinks in the path of a file URL.

func resolvingSymlinksInPath() -> URL

Resolves any symlinks in the path of a file URL.

func standardize()

Standardizes the path of a file URL.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software