Skip to content

Instance MethodFoundationEssentials

appending(component:directoryHint:)

iOS 16.0+ iPadOS 16.0+ Mac Catalyst 16.0+ macOS 13.0+ tvOS 16.0+ watchOS 9.0+
Returns a URL constructed by appending the given path component to self. For non-file URLs, this method percent-encodes any path separators (/) in the path component before appending.
func appending<S>(component: S, directoryHint: URL.DirectoryHint = .inferFromPath) -> URL where S : StringProtocol

Parameters

component

A path component to append to the receiver.

directoryHint

A hint to whether this URL will point to a directory.

Return Value

The new URL

Discussion

Note

For compatibility, this method does not percent-encode any path separators (/) if the URL has a file scheme.