Skip to content

InitializerFoundationEssentials

init(filePath:directoryHint:relativeTo:)

iOS 16.0+ iPadOS 16.0+ Mac Catalyst 16.0+ macOS 13.0+ tvOS 16.0+ watchOS 9.0+
Creates a file URL that references a path you specify as a string.
init(filePath path: String, directoryHint: URL.DirectoryHint = .inferFromPath, relativeTo base: URL? = nil)

Parameters

path

The location in the file system, as a string.

directoryHint

A hint to the initializer to indicate whether the path is a directory, or to instruct the initializer to make this determination.

base

A URL that provides a file system location that the path extends.

Discussion

If an empty string is used for the path, the system interprets it as “.”.