In the Swift URL Documentation, there are several ways to add a String
as part component into the URL
. But which one should I use?
I know the difference between append()
and appending()
, the former is to create new URL while the later is to append it directly into this one. But what’s the difference between appending(path:)
, appending(component:)
, and appendingPathComponent()
? I cannot find any difference? Which one should I use?
func appending<S>(path: S, directoryHint: URL.DirectoryHint) -> URL
func appending<S>(component: S, directoryHint: URL.DirectoryHint) -> URL
func appendingPathComponent(String) -> URL
func appendingPathComponent(String, isDirectory: Bool) -> URL